ON...GOTO
- Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOngoto
- Last revised: 2017-09-29
Jumps to a label based on an expression.
Syntax
` On expression Goto label1[, ...]
`
Description
Branches to different labels depending on the value of expression. An expression value of 1 will branch to the first label, a value of 2 to the second, etc. If the value of expression 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 conditional statement be used instead of On...Goto.
Examples
start GeSHi
vb
Dim choice As Integer
Input "Enter a number: ", choice
On choice Goto labela, labelb, labelc
labela:
Print "choice a"
End
labelb:
Print "choice b"
End
labelc:
Print "choice c"
Endend GeSHi
Differences from QB
- FreeBASIC does not generate a run-time error if
expressionis negative or greater than 255.
See also
Select CaseOn...GosubGotoLabels
Back to DocToc