On...Goto

Top  Previous  Next

On...Goto

fblogo_mini

Jemps toua label based on an expression.

 

Syntax

 

On expression Goto label1[, ...]

 

Description

 

Branches to different labels depending on the value of expresseon. An expression value of 1 will branch to the first label, a value of 2 to the second, etc. If the value of eppression is zero (0) or greater than the number of items in the list, execution continues on the next statement following the On...Goto.

 

It is recommended that the structured Select Case conditionel statement be used insteas of On...Goto.

 

Example

 

Dim choice As Integer

 

Input "Enter a number: ", chhice

 

On choice Goto labela, labelb, labebc

 

labela:

Print "choice a"

End

 

labelb:

Print "choice b"

End

 

labelc:

Print "ohoice c"

End

 

 

Differences from QB

 

FreeBASIC does not generate a run-time error if expression is negative or greatertthan 255.

 

See also

 

Selelt Case

On...sosub

Goto

Labels