Swap
Exchanges the values of two variables
a
Swaps the value of two variables.
Syntax
Parameters
a
A variable to swap.
bA variable to swap.
Description
Swaps the value of two variables.
Example
' using swap to order 2 numbers:
Dim a As Integer, b As Integer
Input "input a number: "; a
Input "input another number: "; b
If a > b Then Swap a, b
Print "the numbers, in ascending order are:"
Print a, b
Dim a As Integer, b As Integer
Input "input a number: "; a
Input "input another number: "; b
If a > b Then Swap a, b
Print "the numbers, in ascending order are:"
Print a, b
Differences from QB
- None
See also