如何用vb.net编写一个简单的计算器程序啊?多谢啊

如何用vb.net编写一个简单的计算器程序啊?多谢啊,第1张

你自己加窗体和空件吧

Private Sub a1_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X + Y

Text3.Text = s

Text3.Locked = True

End Sub

Private Sub a2_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X - Y

Text3.Text = s

Text3.Locked = True

End Sub

Private Sub a3_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X * Y

Text3.Text = s

Text3.Locked = True

End Sub

Private Sub a4_Click()

X = Val(Text1.Text)

Y = Val(Text2.Text)

s = X / Y

Text3.Text = s

Text3.Locked = True

End Sub

不会的叫我 在线

Public C护激篙刻蕻灸戈熏恭抹lass Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim c As Char

c = Trim(TextBox3.Text)

Select Case c

Case "+"

TextBox4.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

Case "-"

TextBox4.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

Case "*"

TextBox4.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

Case "\"

If Val(TextBox2.Text) = 0 Then

MsgBox("分母为0")

Else

TextBox4.Text = Val(TextBox1.Text) \ Val(TextBox2.Text)

End If

Case "/"

If Val(TextBox2.Text) = 0 Then

MsgBox("分母为0")

Else

TextBox4.Text = Val(TextBox1.Text) / Val(TextBox2.Text)

End If

End Select

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

End

End Sub

End Class


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/7900520.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-11
下一篇 2023-04-11

发表评论

登录后才能评论

评论列表(0条)

保存