Visual Basic

This is a discussion on Visual Basic within the Tech Board forums, part of the Community Boards category; It's a bit of a longshot, as it's not exactly a common programming language, but here is the first place ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    5

    Visual Basic

    It's a bit of a longshot, as it's not exactly a common programming language, but here is the first place I thought off to ask. Basically, I want to learn C++, but my brother, who knows it, and uses it everyday at his job maintains it's too complicated for me, so he wants me to try and program some Visual Basic. What he wants me to do is:

    "write a program to draw whatever amount of circles the user specifies at random positions."

    It seems simple enough, but there's a lack of Visual Basic Tutorials out there which is somewhat hindering my progress. I'm not asking anyone to actually program it, I just need help with this one piece. My code:

    Code:
    input "How many circles would you like to put in? ", circle$
    print "You have chosen " + circle$ + " .This will now be drawn in Graphics Output below.";
    
    
    if circle$ = 4 then print "Cool"
    Now, when I try to run it, it gives me "Syntax Error on line 8" (which is the line in bold). What I'm trying to do, is to say that if the user inserted 1 for circle$, that it prints "Cool", but it doesn't seem to know what circle$ is.

    I would greatly appreciate the help!

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,467
    What version of Visual Basic are you using? I can't seem to remember an input statement ever. There's input #, which will read data from a file and assign it to a variable.

    Also print is looking odd to me. Since this is a method, not a statement. The only print-like statement is print #.

    Meanwhile circle$ has not been declared. You should add Dim circle$ As Integer to your code. However, I'm not familiar with this type of Visual Basic syntax you are providing... is it VB.Net?

    If that is the case, you are better of on other forums out there on the web.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    5
    Well.. I'm programming it on this.

    And the tutorials tell me squat all..

  4. #4
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,070
    Quote Originally Posted by Nanor
    Well.. I'm programming it on this.
    Which isn't Visual Basic.
    Memorial University of Newfoundland
    Computer Science

    Mac and OpenGL evangelist.

  5. #5
    Insane Game Developer Nodtveidt's Avatar
    Join Date
    Nov 2006
    Location
    Isabela, PR
    Posts
    105
    You cannot Dim circle$ As Integer, the $ implies a String data type. In VB, it need not be explicitly declared if it has the $. All variables in VB are of type Variant if not explicitly declared (which is rather wasteful and inefficient, so avoid using the Variant type if possible). Also, "Input" and "Print" no longer exist in their legacy forms in VB. For Input, you'd have to either use the inputbox function or check the text of a textbox (there are other ways as well but those are the two most common). The Debug object does have a Print method (Debug.Print) but it will only work in the IDE's Immediate window. A suggestion as well for VB...don't use + for string concatenation, as using + converts to Variant and then back to String (very inefficient), use & for string concatenation always.

    But you can pretty much ignore all of this if you're using BASIC-256. VB and BASIC-256 share very little in common aside from the BASIC norms. You have a variable type clash in your code...

    if circle$ = 4 then print "Cool"

    is invalid. You're looking for a string literal, and your code is looking at a numeric constant. You can either use a string literal, or change your variable type.

    if circle$ = "4" then print "Cool" <-- string literal
    if circle = 4 then print "Cool" <-- change variable type

    Furthermore, circle is a reserved keyword in BASIC-256. You cannot have a variable with the same name as a keyword, even if the case is different. By nature, BASIC variables are case-insensitive, unlike C, so you need to use a different name. I would suggest iCircle if you change the variable type, or sCircle if you leave it as a string variable.
    Code:
    cout << "Language comparisons are dumb";
    echo("Language comparisons are dumb");
    PRINT "Language comparisons are dumb"
    alert ("Language comparisons are dumb")

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 11-22-2007, 11:13 PM
  2. Run Visual Basic code inside C++?
    By torbjoen in forum Windows Programming
    Replies: 8
    Last Post: 07-31-2002, 11:41 PM
  3. <list>
    By Unregistered in forum C++ Programming
    Replies: 9
    Last Post: 02-24-2002, 03:07 PM
  4. Visual Basic C++
    By gussguss in forum C++ Programming
    Replies: 8
    Last Post: 11-20-2001, 09:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21