VB Calculator program

 Use the below coding to create a calculator program using VB (Visual Basic) Software.




Public Curval As Double
Public Preval As Double
Public choice As String
Public result As Double

Private Sub cmd_Click(Index As Integer)
Text1.Text = Text1.Text & cmd(Index).Caption
Curval = Val(Text1.Text)
End Sub

Private Sub Command10_Click()
Text1.Text = " "
Preval = Curval
Curval = 0
choice = "-"
End Sub

Private Sub Command14_Click()
Select Case choice
Case "+"
result = Preval + Curval
Text1.Text = Str(result)
Case "-"
result = Preval - Curval
Text1.Text = Str(result)
Case "/"
result = Preval / Curval
Text1.Text = Str(result)
Case "*"
result = Preval * Curval
Text1.Text = Str(result)
End Select
Curval = result
End Sub

Private Sub Command15_Click()
Text1.Text = " "
Preval = Curval
Curval = 0
choice = "/"
End Sub


Private Sub Command16_Click()
Text1.Text = " "
Preval = Curval
Curval = 0
choice = "*"
End Sub

Private Sub Command17_Click()
Curval = -Curval
Text1.Text = Str(Curval)
End Sub

Private Sub Command18_Click()
Curval = Preval = 0
Text1.Text = " "
End Sub

Private Sub Command5_Click()
Text1.Text = " "
Preval = Curval
Curval = 0
choice = "+"
End Sub
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment