|
-
Feb 20th, 2002, 07:52 PM
#1
Thread Starter
Lively Member
I cant place an End If !!!
For some reason or another whith all of the if statements below
when I put an End If after them I get an error saying: End if must be preceeded by a matching If... The code works fine exept its causing bugs in the rest of the code. Any ideas? Besides a select case.. Cause I cant put an end if inside a Select case either!
Code:
Public Function Todo()
System.Console.WriteLine(">--------------------------------------------<")
System.Console.Write("What do you think we should do?")
sInput = System.Console.ReadLine()
If sInput = "look" Then Call Locations()
If sInput = "orders please" Then Call Locations()
If sInput = "Drop Badge" Then Badge = False
Console.WriteLine("OK, I droped the badge!") : Call Start()
End Function
12/32/84 - I need some code to make me a sandwhich.
-
Feb 20th, 2002, 07:57 PM
#2
Frenzied Member
To save yourself some heartache, just use a select statement, or just put the end if after each if statement.
Dont gain the world and lose your soul
-
Feb 20th, 2002, 08:06 PM
#3
Frenzied Member
Try this:
Code:
Public Function Todo()
System.Console.WriteLine(">--------------------------------------------<")
System.Console.Write("What do you think we should do?")
sInput = System.Console.ReadLine()
Select sInput
Case "look", "orders please"
Call Locations()
Case "Drop Badge"
Badge = False
Console.WriteLine("OK, I droped the badge!")
Call Start()
Case else
Console.WriteLine("Invalid data entered"
End Select
End Function
Dont gain the world and lose your soul
-
Feb 21st, 2002, 07:02 AM
#4
New Member
You do not need an End If when the the statement(s) to be executed are on the same line as the If.
You could do something like:
Dim li_Var As Int16 = 1
If li_Var = 1 Then Call Locations()
or multiple statements:
If li_Var = 1 Then Call Locations() : Call Start()
Which is perfectly valid, but not very readable.
When the Statement(s) is not on the same line then you require the End If:
If li_Var = 1 Then
Call Locations()
End If
As for your other bugs, then you _have_ other bugs and this is not your problem.
As DevGrp has shown above though, would be better in a case.
Hope this helps,
Mike
-
Feb 21st, 2002, 03:01 PM
#5
Thread Starter
Lively Member
Thanks for the help. I converted it to select case.
And I found the bug. After searching for about an
hour, I noticed that one of the room names had
the first letter in lowercase while the rest had
the first letter in uppercase! All that work for
on single charactor.....
12/32/84 - I need some code to make me a sandwhich.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|