Tuesday, September 3, 2019

HOW TO SWAP TWO NUMBER'S USING VB PROGRAMMING.

Hi Friends Today i will show you how you can be Calculate Swap in VB(Visual Basic 6.0)


  • You need to insert Two Label Control's.
  • And another Control's need to insert is  Two Text box Control.
  • One Command button is placed to the form.
  • As Shown in Picture Arrange it.
  • Also Placed Another Label for Output or Display for Swapping Of Number . 
  • In this Example I used default names of Control.  
  • Here We Use an Function(vbCrLf) which is used to separate line Ok.
  • Also we concatenate the Strings value to show proper Output in Label Control. 

Coding of Swapping Of Number

Private Sub cmdClick_Click()
    Dim n1 As Integer, n2 As Integer, temp As Integer
    n1 = Val(Text1.Text)
    n2 = Val(Text2.Text)
    temp = n1
    n1 = n2
    n2 = temp
    lblOutput.Caption = "First Number is " & n1 & vbCrLf & "Second Number is " & n2
End Sub

Code Window

Output View

Design View



No comments:

Post a Comment