![]() |
IOBit Software
|
|
|
||||||
| Programming Place to discuss programming including HTML, Java, C++, MySQL and others. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
VBS
Hey guys, This will probably be regarded as a silly question, but it's all good. Now, I know for a fact that what I've written has both numerous syntax and Parenthesis+Sub errors. Dim x Dim y set oShell = createobject("wscript.shell") x = MsgBox("Fatal error has occured, must play a game to continue.", 4+16, "Fatal Error") if x = "7" then MsgBox("Error, cannot decline challenge.", 0, "Fatal Error") end if y = InputBox("Guess the number from 1 to 100", "Fatal Error") if y = "77" then MsgBox("It's your lucky day!", 0, "Fatal Error") end if else if MsgBox("You lose!", 0, "Fatal Error") end if While I would appreciate someone fixing it for me, what I'd really want is someone to explain the rules to me, since I'm pretty new to this scripting game. |
| Sponsored links |
|
|
|
#2
|
||||
|
||||
|
The debugger tells you exactly what's going wrong and where.
Code:
Dim x
Dim y
x = MsgBox("Fatal error has occured, must play a game to continue.", 4+16, "Fatal Error")
if x = 7 then
MsgBox "Error, cannot decline challenge.", 0, "Fatal Error"
end if
y = InputBox("Guess the number from 1 to 100", "Fatal Error")
if y = "77" then
MsgBox "It's your lucky day!", 0, "Fatal Error"
else
MsgBox "You lose!", 0, "Fatal Error"
end if
If you use the MsgBox Function to assign a variable then you have to enclose the parameters into parentheses. If you don't assign a variable or you don't use the returned value inline the parentheses would cause an error. The syntax for if is: Code:
If <condition> Then <code for true result> Else <code for false result> End If Regards GermanOne |
![]() |
| Tags |
| error, explain, syntax, vbs |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Syntax Error | PamLeah | Software | 2 | 10-27-08 00:14 |
| VBScript syntax error | Kniht | Software | 2 | 04-20-06 15:48 |
| A syntax error installing xp pro | SpAzZqNK | Software | 3 | 05-22-05 10:36 |
| Invalid syntax error in IE | CDank3 | Software | 9 | 05-03-05 12:34 |
| Syntax Error | Dolly | Software | 1 | 04-17-05 13:35 |