有VB编写一个,界面控制的计算! 谁会 谢谢
vb编程计算器
- 提问者网友:了了无期
- 2021-04-13 22:33
- 五星知识达人网友:像个废品
- 2021-04-13 22:55
Dim x As String
Private Sub Command1_Click()
Text1.Text = Text1.Text & "1"
End Sub
Private Sub Command10_Click()
Text1.Text = Text1.Text & "6"
End Sub
Private Sub Command11_Click()
Text1.Text = Text1.Text & "9"
End Sub
Private Sub Command12_Click()
If Label1.Caption = "+" Then
Text1.Text = Trim(Str(Val(x) + Val(Text1.Text)))
End If
If Label1.Caption = "-" Then
Text1.Text = Trim(Str(Val(x) - Val(Text1.Text)))
End If
If Label1.Caption = "*" Then
Text1.Text = Trim(Str(Val(x) * Val(Text1.Text)))
End If
If Label1.Caption = "/" Then
If Val(Text1.Text) = 0 Then
Text1.Text = "除数不能为零"
Else
If -1 < Val(x) / Val(Text1.Text) And Val(x) / Val(Text1.Text) < 0 Then
Text1.Text = Trim("-0" & Trim(Str(Abs(Val(x) / Val(Text1.Text)))))
Else
If 0 < Val(x) / Val(Text1.Text) And Val(x) / Val(Text1.Text) < 1 Then
Text1.Text = Trim("0" & Trim(Str(Val(x) / Val(Text1.Text))))
Else
Text1.Text = Trim(Str(Val(x) / Val(Text1.Text)))
End If
End If
End If
End If
End Sub
Private Sub Command13_Click()
x = Text1.Text
Text1.Text = ""
Label1.Caption = "+"
End Sub
Private Sub Command14_Click()
x = Text1.Text
Text1.Text = ""
Label1.Caption = "-"
End Sub
Private Sub Command15_Click()
x = Text1.Text
Text1.Text = ""
Label1.Caption = "*"
End Sub
Private Sub Command16_Click()
x = Text1.Text
Text1.Text = ""
Label1.Caption = "/"
End Sub
Private Sub Command17_Click()
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command18_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Text1.Text = Text1.Text & "4"
End Sub
Private Sub Command3_Click()
Text1.Text = Text1.Text & "7"
End Sub
Private Sub Command4_Click()
Text1.Text = Text1.Text & "0"
End Sub
Private Sub Command5_Click()
Text1.Text = Text1.Text & "2"
End Sub
Private Sub Command6_Click()
Text1.Text = Text1.Text & "5"
End Sub
Private Sub Command7_Click()
Text1.Text = Text1.Text & "8"
End Sub
Private Sub Command8_Click()
Text1.Text = Text1.Text & "."
End Sub
Private Sub Command9_Click()
Text1.Text = Text1.Text & "3"
End Sub
Private Sub Form_Load()
Label1.Visible = False
End Sub
- 1楼网友:像个废品
- 2021-04-14 00:51
- 2楼网友:英雄的欲望
- 2021-04-13 23:51
说点具体点,要不没法做啊