GoSub...Return Statement

Calls a subroutine that is indicated by a label inside a Sub or a Function. The statements following the label are executed until the next Return statement. Afterwards, the program continues with the statement that follows the GoSub statement.

Syntax:


GoSub label[:]

Parameters:

label: A line identifier indicating where to continue execution. The scope of a label in that of the routine it belongs to.

The GoSub statement calls a local subroutine indicated by a label from within a subroutine or a function. The name of the label must end with a colon (":").


  Sub/Function foo
      ' statements
      GoSub label
      ' statements
      Exit Sub/Function
  label:
      ' statements
      Return
  End Sub/Function
āĻ¸āĻ¤āĻ°ā§āĻ•āĻ¤āĻžāĻŽā§‚āĻ˛āĻ• āĻ†āĻ‡āĻ•āĻ¨

āĻ¯āĻĻāĻŋ āĻĒā§āĻ°ā§‹āĻ—ā§āĻ°āĻžāĻŽāĻŸāĻŋāĻ¤ā§‡ āĻāĻŽāĻ¨ āĻāĻ•āĻŸāĻŋ āĻĒā§āĻ°āĻĻāĻžāĻ¨ āĻ¸ā§āĻŸā§‡āĻŸāĻŽā§‡āĻ¨ā§āĻŸ āĻĨāĻžāĻ•ā§‡ āĻ¯āĻžāĻ° āĻĒā§‚āĻ°ā§āĻŦā§‡ GoSub āĻŦāĻŋāĻĻā§āĻ¯āĻŽāĻžāĻ¨ āĻ¨ā§Ÿ, āĻ¤āĻžāĻšāĻ˛ā§‡ LibreOffice āĻŦā§‡āĻ¸āĻŋāĻ• āĻāĻ•āĻŸāĻŋ āĻ¤ā§āĻ°ā§āĻŸāĻŋ āĻŦāĻžāĻ°ā§āĻ¤āĻž āĻĒā§āĻ°āĻĻāĻžāĻ¨ āĻ•āĻ°ā§‡ āĻĨāĻžāĻ•ā§‡āĨ¤ āĻĒāĻ°āĻŦāĻ°ā§āĻ¤ā§€ āĻĒā§āĻ°āĻĻāĻžāĻ¨ āĻ¸ā§āĻŸā§‡āĻŸāĻŽā§‡āĻ¨ā§āĻŸā§‡ āĻĒā§ŒāĻāĻ›āĻžāĻ° āĻĒā§‚āĻ°ā§āĻŦā§‡ āĻ¸āĻžāĻŦ āĻ…āĻĨāĻŦāĻž āĻĢāĻžāĻ‚āĻļāĻ¨ āĻĨā§‡āĻ•ā§‡ āĻāĻ•āĻŸāĻŋ āĻĒā§āĻ°ā§‹āĻ—ā§āĻ°āĻžāĻŽ āĻ…āĻĒāĻ¸āĻžāĻ°āĻŖ āĻ¨āĻŋāĻļā§āĻšāĻŋāĻ¤ āĻ•āĻ°āĻžāĻ° āĻœāĻ¨ā§āĻ¯ Exit Sub āĻ…āĻĨāĻŦāĻž Exit Function āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻ•āĻ°āĻž āĻšā§ŸāĨ¤


āĻ¨āĻŋāĻšā§‡āĻ° āĻ‰āĻĻāĻžāĻšāĻ°āĻŖāĻŸāĻŋ GoSub āĻāĻŦāĻ‚ Return āĻāĻ° āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻŦā§āĻ¯āĻžāĻ–ā§āĻ¯āĻž āĻ•āĻ°ā§‡ āĻĨāĻžāĻ•ā§‡āĨ¤ āĻĒā§āĻ°ā§‹āĻ—ā§āĻ°āĻžāĻŽā§‡āĻ° āĻāĻ•āĻŸāĻŋ āĻ…āĻ‚āĻļ āĻĻā§āĻ‡āĻŦāĻžāĻ° āĻšāĻžāĻ˛āĻžāĻ¨ā§‹āĻ° āĻŽāĻžāĻ§ā§āĻ¯āĻŽā§‡, āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ°āĻ•āĻžāĻ°ā§€ āĻĻā§āĻŦāĻžāĻ°āĻž āĻ¸āĻ¨ā§āĻ¨āĻŋāĻŦā§‡āĻļāĻ•ā§ƒāĻ¤ āĻĻā§āĻ‡āĻŸāĻŋ āĻ¸āĻ‚āĻ–ā§āĻ¯āĻžāĻ° āĻŦāĻ°ā§āĻ—āĻŽā§‚āĻ˛ āĻ—āĻŖāĻ¨āĻž āĻ•āĻ°āĻž āĻšā§ŸāĨ¤

Example:


Sub ExampleGoSub
Dim iInputa As Single
Dim iInputb As Single
Dim iInputc As Single
    iInputa = Int(InputBox("Enter the first number: ","NumberInput"))
    iInputb = Int(InputBox("Enter the second number: ","NumberInput"))
    iInputc=iInputa
    GoSub SquareRoot
    Print "The square root of";iInputa;" is";iInputc
    iInputc=iInputb
    GoSub SquareRoot
    Print "The square root of";iInputb;" is";iInputc
    Exit Sub
SquareRoot:
    iInputc=sqr(iInputc)
    Return
End Sub

Please support us!