This example gets a name from the user and then branches to a subroutine to check the input. If the user clicks Cancel or enters a blank name, the program terminates; otherwise, the name is set to MICHAEL, and a message is displayed.
Sub Main()
uname$ = Ucase$(InputBox$("Enter your name:","Enter Name"))
GoSub CheckName
MsgBox "I'm looking for MICHAEL, not " & uname$
Exit Sub
CheckName:
If (uname$ = "") Then
GoSub BlankName
ElseIf uname$ = "MICHAEL" Then
GoSub RightName
Else
GoSub OtherName
End If
Return
BlankName:
MsgBox "No name? Clicked Cancel? I'm shutting down."
Exit Sub
RightName:
Msgbox "Hey, MIKE where have you been?"
End
OtherName:
Return
End Sub
|