Tuesday, February 22, 2011

Write a visual Basic Calculator Programs

WAP in VB to Calculator.
___________________________________
Dim num1 As Double
Dim num2 As Double
Dim sum As Double
Dim choice As String
Private Sub cmd_Click(Index As Integer)
Label1.Caption = Label1.Caption & cmd(Index).Caption
num1 = Val(Label1.Caption)
End Sub

Private Sub Command1_Click()
num1 = -num1
Label1.Caption = Str(num1)
End Sub

Private Sub Command13_Click()
num2 = num1 = 0
Label1.Caption = ""
End Sub

Private Sub Command14_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "-"
End Sub

Private Sub Command15_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "*"
End Sub

Private Sub Command16_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "/"
End Sub

Private Sub Command17_Click()
Select Case choice
Case "+"
sum = num2 + num1
Label1.Caption = Str(sum)
Case "-"
sum = num2 - num1
Label1.Caption = Str(sum)
Case "*"
sum = num2 * num1
Label1.Caption = Str(sum)
Case "/"
sum = num2 / num1
Label1.Caption = Str(sum)
End Select
End Sub

Private Sub Command18_Click()
End
End Sub

Private Sub Command4_Click()
Label1.Caption = ""
num2 = num1
num1 = 0
choice = "+"
End Sub

Private Sub Form_Load()

End Sub
__________________________________
OUTPUT
__________________________________





____________________________________
DOWNLOAD
____________________________________

Download its form

Download its Image



No comments:

Post a Comment