Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Case syntax?

Status
Not open for further replies.

mossimo

Programmer
Dec 31, 2003
17
US
Is there any real difference between these two ways of writing select case statements?

Code:
Select Case(sVariable)
  Case “1” : Do(this) : Do(that)
  Case “2” : Do(thistwo) : Do(thattwo)
End Select

OR THIS:

Code:
Select Case(sVariable)
  Case “1”
    Do(this)
    Do(that)
  Case “2”
    Do(thistwo)
    Do(thattwo)
End Select

Cheers
mossimo

 
Hello mossimo,

They are the same. ":" is just a separator for successive instructions placing on the same line.

Only problem, as I see it, is your use of "“”". They won't do for string delimiter.

Further minor issue is your renderment of select case:
Select Case(sVariable)
It is ambiguous here as it might be mistakenly conceived case as a function of some kind. Encircling a variable is no problem, sometimes necessary. If you use it here, distance it with the case keyword
Select Case sVariable
or
Select Case (sVariable)

regards - tsuji
 

Yes you are correct it should actually be Select Case sVariable.

tsuji said:
Only problem, as I see it, is your use of "“”". They won't do for string delimiter

It looks like copy and pasting wasn’t a good idea because it should be "1" and not “1”

Thanks tsuji

Cheers
mossimo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top