Remember SWAP?

I was surprised to learn that the SWAP command was not implementedin Visual Basic when I read a letter in the February 1996 issueof VBPJ requesting that Microsoft bring to Visual Basicthe 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 workwith other data types.

Here is an example:

 Option ExplicitPrivate 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
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: