Use VB simple to do calculator

Source: Internet
Author: User

Dim A as double, B as double

Dim C as String

Private Sub Command10_click ()

Text2.text = Text2.text & "2"

End Sub

Private Sub Command11_click ()

Text2.text = Text2.text & "3"

End Sub

Private Sub Command12_click ()

A = Text2.text

Text2.text = ""

c = "+"

End Sub

Private Sub Command13_click ()

Text2.text = Text2.text & "."

End Sub

Private Sub Command14_click ()

A = Text2.text

Text2.text = ""

c = "/"

End Sub

Private Sub Command15_click ()

A = Text2.text

Text2.text = ""

c = "*"

End Sub

Private Sub Command16_click ()

A = Text2.text

Text2.text = ""

c = "-"

End Sub

Private Sub Command18_click ()

Text2.text = ""

End Sub

Private Sub Command19_click ()

b = Text2.text

If a = "0" Or B = "0" then MsgBox "divisor is 0", vbexclamation, "Tips": Exit Sub

Select Case C

Case "+"

Text2.text = Val (a) + Val (b)

Case "-"

Text2.text = Val (a)-Val (b)

Case "*"

Text2.text = Val (a) * Val (b)

Case "/"

Text2.text = Val (a)/Val (b)

If Val (a) = 0 Then

MsgBox "Divisor cannot be:" 0 ""

Text2.text = ""

End If

If Val (b) = 0 Then

MsgBox "Divisor cannot be:" 0 ""

Text2.text = ""

End If

End Select

End Sub

Private Sub Command2_Click ()

Text2.text = Text2.tex T & "6"

End Sub

Private Sub Command3_Click ()

Text2.text = Text2.text & "5"

End Sub

Private Sub Command4_click ()

Text2.text = Text2.text & "4"

End Sub

Private Sub Command5_click ()

Text2.text = text2.text & "9"

End Sub

Private Sub Command6_click ()

Text2.text = text2.text & "8"

End Sub

Private Sub Command7_click ()

Text2.text = Text2.text & "7"

End Sub

Private Sub Command8_click ()

Text2.text = Text2.text & "0"

End Sub

Private Sub Command9_click ()

Text2.text = Text2.text & "1"

End Sub

Use VB simple to do calculator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.