Sinisterly
[VB.NET]Swaping - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Visual Basic & .NET Framework (https://sinister.li/Forum-Visual-Basic-NET-Framework)
+--- Thread: [VB.NET]Swaping (/Thread-VB-NET-Swaping)



[VB.NET]Swaping - 1234hotmaster - 06-24-2011

I made this function in which you can switch values of 2 dimensions. Its not what you can call Hard but i thought sharing it wont hurt Smile

Code:
Public Function Swap(ByVal First, ByVal Second) As String Dim T T = First First = Second Second = T Return First & " " & Second End Function


How it works?

Code:
MsgBox(Swap(20, 10))

Code:
MsgBox(Swap("hello", "world"))

It can work for a types including string, integer, byte, char, long, short, decimal, ...


RE: [VB.NET]Swaping - Coder-san - 06-24-2011

You could just do this Smile

Code:
Public Function Swap(ByVal First, ByVal Second) As String Return Second & " " & First End Function



RE: [VB.NET]Swaping - 1234hotmaster - 06-24-2011

oh sh*t i really feel dumb... my teacher really made me stupid XD

like using a 10 lines code for reversing a number instead of

CInt(StrReverse(CStr(number)))

coder please delete or close this thread its really humiliating :'(


RE: [VB.NET]Swaping - Coder-san - 06-24-2011

Locked on request.