Showing posts with label swap two numbers in vb6. Show all posts
Showing posts with label swap two numbers in vb6. Show all posts

Saturday, September 2, 2017

Swap Two Numbers in Visual Basic 6

In this article I would like to share with you a very simple program that I wrote in Microsoft Visual Basic 6 to ask the user to give two numbers and then our program will swap or interchange the two number being provided by our user. The code uses a procedure that I wrote in Visual Basic 6 I hope you will find my work useful. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Sample Program Output



Program Listing

'Swap Two Numbers in Visual Basic 6
'Date : September 2, 2017
' Written By: Mr. Jake R. Pomperada, MAED-IT
' Mandaluyong City, Metro Manila Philippines

Public Sub SwapTwoNumbers(Var1 As Integer, Var2 As Integer)
  Dim TempVar As Integer
  TempVar = Var1
  Var1 = Var2
  Var2 = TempVar
  
  Text3.Text = Var1
  Text4.Text = Var2
End Sub


Private Sub Command1_Click()
Dim A As Integer
Dim B As Integer

A = Val(Text1.Text)
B = Val(Text2.Text)

SwapTwoNumbers A, B

End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub