Imports System
Public Module Module1
Public Sub Main()
Console.WriteLine("Welcome to memory swap.")
'declaration of variables
'Dim X as string = "Tom"
'Dim Y as string = "Susan"
'Dim Z as string = ""
'Goal is to swap the variables' values.
'how do I swap the values?
'hm... perhaps I should find a way to store the memory through readlines...
'will user input be forbidden? hmmm? 'Literals are entirely forbidden*
'cannot use if/then statements, unless I want console to change the variables back to their first values. Heh.
'how do they change? X = Y and Y = X just make them both Tom. How do I really, truly, swap their values?
'here is a representation of this crap.
'-X- __ -Y- '- - _X_ -Y- '-Y- _X_ - - '-Y- __ -X-
'essentially, I need a third party to do this.
'1. X is put in the third party.
'2. Y is put in X's former spot.
'3. X is put in Y's former spot.
'Ah! I need a third variable, do I?
'Z will store X. X will grab Y. Y will grab Z.
'Z = X
'X = Y
'Y = Z
'output messages
'Console.writeline("The value of X is now " + X + ".")
'Console.writeline("The value of Y is now " + Y + ".")
'Here is the code itself.
Dim X as string = "Tom"
Dim Y as string = "Susan"
Dim Z as string = " "
Z = X
X = Y
Y = Z
Console.writeline("The value of X is now " + X + ".")
Console.writeline("The value of Y is now " + Y + ".")
'Now let's make a package!
End sub
Public Sub Swap(byref a as string, byref b as string) 'byref appears to be a way to a way to declare variables?
Dim z as string = " "
z = a
a = b
b = z
End Sub
End Module