Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'Exchange Numbers and Strings without using a third Variable
- 'https://ayra.ch
- OPTION EXPLICIT
- DIM iA
- DIM iB
- DIM sA
- DIM sB
- iA=1
- iB=10
- sA="<Word 1>"
- sB="<Word 2>"
- 'Before
- CALL MsgBox("A: " & CSTR(iA) & vbCrLf & "B: " & CSTR(iB),vbInformation,"Before: Number")
- CALL MsgBox("A: " & CSTR(sA) & vbCrLf & "B: " & CSTR(sB),vbInformation,"Before: String")
- 'Exchange Number
- iA=iA+iB
- iB=iA-iB
- iA=iA-iB
- 'Exchange String
- sA=sA & sB
- sB=Left(sA,Len(sA)-Len(sB))
- sA=Right(sA,Len(sA)-Len(sB))
- 'After
- CALL MsgBox("A: " & CSTR(iA) & vbCrLf & "B: " & CSTR(iB),vbInformation,"After: Number")
- CALL MsgBox("A: " & CSTR(sA) & vbCrLf & "B: " & CSTR(sB),vbInformation,"After: String")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement