VB.NET怎么编模拟袖珍计算器的完整程序?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
如何用vb.net编写一个简单的计算器程序?。慷嘈话?/h2>你自己加窗体和空件吧
Private Sub a1_Click()
X = Val(Text1.Text)
Y = Val(Text2.Text)
s = XY
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
不会的叫我 在线谈
您好,我想用vb 。net编一个计算器,就是设置了几个数字键,摁一下显示一个数字,比如输入67该怎么编写操作过程:
1获取你摁vb.net数学计算器的第一个数字值,比如6,把它转换成字符串"6",设置在文本框txtNum中.
2获取你按vb.net数学计算器的第二个数字值,比如7,转换成字符串,设置文本框
txtNum.text= "7" 这样就出现了"67"的显示了.
VB.net作业,用VB做一个简单的计算器.我用VB做的你看能不能用
Public b
Public c
Public d
Public e
Public f
Private Sub Command14_Click()
d = ""
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Exit Sub
'c = Text1.Text
If b = "" Then Exit Sub
If e = " " Then
d = fb
Else
If e = "-" Then
d = f - b
Else
If e = "*" Then
d = f * b
Else
If e = "/" Then
If b = 0 Then
MsgBox "被除数不能为零!"
Exit Sub
End If
d = f / b
Else
MsgBox "错误操作!"
End If
End If
End If
End If
Text1.Text = d
b = ""
c = ""
e = ""
End Sub
Private Sub Command15_Click()
Text1.Text = ""
b = ""
c = ""
d = ""
e = ""
f = ""
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
Private Sub Command1_Click()
'判断开头有运算符就清零
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
'判断开头有0就禁止输入数字
If Text1.Text = "0" Then
Else
a = 1
'发现运算结果就清零
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text '得到当前操作数
End Sub
Private Sub Command2_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 2
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command3_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 3
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command4_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 4
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command5_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 5
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command6_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 6
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command7_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 7
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command8_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 8
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command9_Click()
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
If Text1.Text = "0" Then
Else
a = 9
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
End If
b = Text1.Text
End Sub
Private Sub Command10_Click()
If b = "" Then Exit Sub
a = " "
e = " "
f = b
Text1.Text = ""
Text1.Text = Text1.Texta
End Sub
Private Sub Command11_Click()
If b = "" Then Exit Sub
f = b
a = "-"
e = "-"
Text1.Text = ""
Text1.Text = Text1.Texta
End Sub
Private Sub Command12_Click()
If b = "" Then Exit Sub
a = "*"
e = "*"
f = b
Text1.Text = ""
Text1.Text = Text1.Texta
End Sub
Private Sub Command13_Click()
If b = "" Then Exit Sub
a = "/"
e = "/"
f = b '把操作数1提取出来
Text1.Text = ""
Text1.Text = Text1.Texta
End Sub
Private Sub Command16_Click()
'判断有运算符就清零
If Text1.Text = " " Or Text1.Text = "-" Or Text1.Text = "*" Or Text1.Text = "/" Then Text1.Text = ""
'判断有零和空值就禁止输入0
'发现运算结果就清零
If d"" Then Text1.Text = "": d = ""
If Text1.Text = "0" Then
Else
a = 0
If d"" Then Text1.Text = "": d = ""
Text1.Text = Text1.Texta
b = Text1.Text
End If
End Sub
有关vb.net制作计算器的问题判断吧,如果点击 按钮,则一个全局变量为1 , -按钮,则全局变量为2.以此类推 , 然后if或case判断哪个数,如果为1 , 就两个数相加 。
【vb.net数学计算器 vb语言计算器】关于vb.net数学计算器和vb语言计算器的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- 华为nova8pro鸿蒙系统好不好,华为nova8pro鸿蒙系统体验
- gis如何修改字段的属性,arcgis修改字段属性
- 网站访问mysql数据库失败,网站访问mysql数据库失败怎么办
- mysql时区怎么修改 修改mysql的时区
- 要买个什么电视,现在要买什么电视好
- 笔记本硬盘温度过高怎么办,笔记本硬盘温度过高怎么解决
- excel如何做目录,excel如何做目录表
- Java照着抄代码有用吗 初学者写java代码用什么软件
- 小程序姓氏图制作方法视频,制作姓氏图片的软件