Thread: vb 2008 exsp
View Single Post
  #2 (permalink)  
Old August 27th, 2008, 02:15 PM
BrianWren BrianWren is offline
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

To post code, click the [[u]#</u>] button. It inserts a pair of tags; put your code between those tgs and it will be fixed spacing, and will be presented literally as you type it.

That bold, red, weird-font is really hard to read...
Your best bet IMO is a Select Case structure:
Code:
    ' Get the input.  In this case it would be in the variable Answer
    ' Then use it in a Select Case statement:

    Select Case Answer
        Case 1
            ' Put the code here that would be at the GoTo Line 1
            ' area.  Alternately, write a routine like:
            RunCase1()
        Case 2
            ' Put the code here that would be at the GoTo Line 2
            ' area.  Alternately, write a routine like:
            RunCase2()
        Case 3
            ' Put the code here that would be at the GoTo Line 3
            ' area.  Alternately, write a routine like:
            RunCase3()
    End Select
    Jumping around with GoTo methods is considered very bad form. It makes programs really hard to read (when trying to figure out what they are supposed to be doing), really hard to maintain (if you need to modify how they work or if you have to repair an error, typo, whatever).

If you go to a job interview, and your portfolio has samples with
Code:
    If Answer = 1 Then
        GoTo 1
    ElseIf Answer = 2 Then
        GoTo 2
    ElseIf Answer = 3 Then
        GoTo 3
    End If
    You can be guaranteed to not get the job...

PS: It is “goes,” not “gose,” and “I” is capitalized when talking about yourself.

And, in reality, some things are actually impossible...
Reply With Quote