locked
Subroutine RRS feed

  • Question

  • how do I work subroutine on small basic
    Thursday, August 25, 2011 12:10 AM

Answers

  • Subroutines are pieces of code that are not run by the compiler, but can be called by using this code: subroutinename(). They can also be used to save many lines of code, because you don't have to type the same thing over and over again. Subroutines are also required for events.

    To make a subroutine, you use the Sub keyword, then the subroutine name, then EndSub keyword after that. Then just type your code between the two keywords. Here is an example:

     

    'This is a program that adds two numbers

    TextWindow.WriteLine("Enter number 1: ")

    readinput()

    num1=return

    TextWindow.WriteLine("Enter number 2: ")

    readinput()

    TextWindow.WriteLine("Your total is: " + (return+num1))

    Sub readinput

       return = TextWindow.ReadNumber()
    EndSub 


    ~~AirWaves!!~~
    Thursday, August 25, 2011 12:48 AM

All replies

  • Subroutines are pieces of code that are not run by the compiler, but can be called by using this code: subroutinename(). They can also be used to save many lines of code, because you don't have to type the same thing over and over again. Subroutines are also required for events.

    To make a subroutine, you use the Sub keyword, then the subroutine name, then EndSub keyword after that. Then just type your code between the two keywords. Here is an example:

     

    'This is a program that adds two numbers

    TextWindow.WriteLine("Enter number 1: ")

    readinput()

    num1=return

    TextWindow.WriteLine("Enter number 2: ")

    readinput()

    TextWindow.WriteLine("Your total is: " + (return+num1))

    Sub readinput

       return = TextWindow.ReadNumber()
    EndSub 


    ~~AirWaves!!~~
    Thursday, August 25, 2011 12:48 AM
  • Please read the Tutorial man it has it covered.
    I love game design and programing.
    Thursday, August 25, 2011 1:02 AM