Wednesday, November 10, 2010

Swap X and Y Values

Make a label 2, textbox 2 and CommandButton 1, and you design like the image below

Option Explicit


Sub Tukar(ByRef x As Single, ByRef y As Single)

Dim Temp As Single

Temp = x

x = y

y = Temp

End Sub


Private Sub cmdTukar_click()

Dim x As Single, y As Single

x = TxtX.Text: y = TxtY.Text

Tukar x, y

TxtX.Text = x: TxtY.Text = y

End Sub

Download Fromnya

0 comments:

Post a Comment