Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Remember SWAP?

I was surprised to learn that the SWAP command was not implemented in Visual Basic when I read a letter in the February 1996 issue of VBPJ requesting that Microsoft bring to Visual Basic the Qbasic Command SWAP.

In a routine I use to sort a file, this code performs the swap. I use character strings for this example, but the logic will work with other data types.

Here is an example:

Option Explicit

Private Sub Form_Load()
        Dim a, b, c As String * 4
        a = "AaAa"
        b = "BbBb"
        Debug.Print a; Spc(5); b 
        'Before the swap
        c = a
        a = b
        b = c
        Debug.Print a; Spc(5); b 
        'After the swap.
End Sub

David Ferber
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date