{{fbdoc item="title" value="ON...GOTO"}}----
Jumps to a label based on an expression.

{{fbdoc item="syntax"}}##
	**On** //expression// **Goto** label1[, ...]
##
{{fbdoc item="desc"}}
	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 ##[[KeyPgSelectcase Select Case]]## conditional statement be used instead of ##**On...Goto**##.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/control/on-goto.bas"}}%%(freebasic)
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"
End
%%

{{fbdoc item="diff"}}
	- FreeBASIC does not generate a run-time error if ##//expression//## is negative or greater than 255.

{{fbdoc item="see"}}
	- ##[[KeyPgSelectcase Select Case]]##
	- ##[[KeyPgOngosub On...Gosub]]##
	- ##[[KeyPgGoto Goto]]##

{{fbdoc item="back" value="CatPgControlFlow|Control Flow"}}