Ayuda de LibreOffice 24.8
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.
GoSub label[:]
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
      ' instrucciones
      GoSub label
      ' instrucciones
      Exit Sub/Function
  label:
      ' instrucciones
      Return
  End Sub/Function
Si el programa encuentra una instrucción Return que no va precedida de GoSub, LibreOffice Basic devuelve un mensaje de error. Use Exit Sub o Exit Function para asegurarse de que el programa salga de una Sub o Function antes de llegar a la siguiente instrucción Return.
El ejemplo siguiente demuestra el uso de GoSub y Return. Al ejecutar una sección de programa dos veces, éste calcula la raíz cuadrada de dos números que ha introducido el usuario.
Sub ExampleGoSub
Dim iInputa As Single
Dim iInputb As Single
Dim iInputc As Single
    iInputa = Int(InputBox("Escriba el primer número: ","Entrada de número"))
    iInputb = Int(InputBox("Escriba el segundo número: ","Entrada de número"))
    iInputc=iInputa
    GoSub SquareRoot
    Print "La raíz cuadrada de";iInputa;" es";iInputc
    iInputc=iInputb
    GoSub SquareRoot
    Print "La raíz cuadrada de";iInputb;" es";iInputc
    Exit Sub
SquareRoot:
    iInputc=sqr(iInputc)
    Return
End Sub