Visual Basic

blacklemons

The Freeman
I'm learning to love programming BASIC, and I can't afford Visual Basic. Does anyone know of a free program that will let me use BASIC?
 
yes that program is used to compile BASIC code so it is runnable. I was just suggesting PASCAL as ur next programming language with its likeness to BASIC.
 
ok so when i use this program

and i Dim my variables

when i run my program it says "BASIC compile halted: syntax error"

this is my program (it just finds an average, i was just testing JustBasic)



nothing wrong with it, so idk

Private Sub Form_Click()

10 Dim S1 As String
20 Dim S2 As Single
30 Dim SA As Single
40 Dim NAME As String

100 NAME = InputBox("What is the name? If done, type '999'")
110 If NAME = "999" Then GoTo 300
120 S1 = InputBox("What is their first score?")
130 S2 = InputBox("What is their second score?")
140 A = ( S1 + S2 ) / 2
150 GoTo 100

300 Print NAME, A
310 Print "DONE"

End Sub
 
Although you're just starting out, it's really bad to get into the habit of using the GoTo command, as it becomes a crutch then.

However, I'm not really fluent in BASIC (more C and C++). All I can say is that a syntax error means you have a misplaced parentheses or something like that.
 
I've taken about a year equivalent of VB in school and I've never even heard of GoTo. 

I have more experience in C++ though. I've taken about 2 years in that.
 
GoTo is a command in pretty much all C type programs that lets you jump to any line in the program. It's considered bad practie though in all the courses I've been in though.
 
I don't really know BASIC, but if I were to guess, I would say the problem would be in line 300. It looks like you are trying to concatenate two strings to print out, and I dont think you can do that with a comma (again, I could be wrong). From the little bit I just researched, you could try using a + instead of a comma, or do it using two separate lines like this:

300 PRINT NAME;
301 PRINT A

The semicolon should put both on the same line.

Or maybe I am wrong, and the comma will work. :p
 
Yeah, syntax could be anything really. Because this batch of code is so small, I'd just say simplify it and then build it back up piece by piece, and see where it starts giving you the error.

Other than that, I would also advise against the "Goto" command. It is helpful, but there's a better way to make loops that makes it easier to combine them with nested loops, sub routines, and the like.
 
the goto command is definitly fine, and it specifies the first line is incorrect no matter what it is

i tried several different lines

i dont think this program supports the language i want it to
 
sry about the double post

i need a program that will run and display stuff like this

Private Sub Form_Click()

10 Dim S1 As String
20 Dim S2 As Single
30 Dim SA As Single
40 Dim NAME As String

100 NAME = InputBox("What is the name? If done, type '999'")
110 If NAME = "999" Then GoTo 300
120 S1 = InputBox("What is their first score?")
130 S2 = InputBox("What is their second score?")
140 A = ( S1 + S2 ) / 2
150 GoTo 100

300 Print NAME, A
310 Print "DONE"

End Sub
 
Hinesmdc said:
the goto command is definitly fine, and it specifies the first line is incorrect no matter what it is

i tried several different lines

i dont think this program supports the language i want it to

Nobody's saying there's anything wrong with your program with the GoTo command itself. It's just bad programming practice.

Have you tried MM's solution?
 
Hinesmdc said:
his solution would only change how the output looks

If you make an error while typing the output, it will still mess up the whole program.

Also, shouldn't it tell you which line is giving you the error when you try to compile it?
 
it always says the first line is the problem, no matter what it is

leading me to believe that this program doesnt support the langauge i use
 
Back
Top