VB求一个科学计算器源代码,谢谢啦
发布网友
发布时间:2022-05-29 08:26
我来回答
共1个回答
热心网友
时间:2023-10-12 18:11
由于本人级别不够,不能上传照片
图片在你的QQ邮箱里
运行界面,编程界面我发到你的邮箱里
Option Explicit
Dim s_id As Integer
Dim s As String
Dim s1 As Double
Function p(x As Double) As Boolean
If InStr(x, ".") = 0 Then
p = False
Else
p = True
End If
End Function
Private Sub C_Click(Index As Integer)
Select Case s_id
Case 0, 2
Text1.Text = Text1.Text & Index
Case 1
Text1.Text = Index
s_id = 2
Case 3
Text1.Text = Index
s_id = 0
End Select
End Sub
Private Sub CmdAdd_Click()
Select Case s_id
Case 0
s = "+"
s1 = Text1.Text
s_id = 1
Case 2
CmdDY_Click
s = "+"
s1 = Text1.Text
s_id = 1
End Select
End Sub
Private Sub CmdBK_Click()
If Len(Text1.Text) > 0 Then
Text1.Text = Mid(Text1.Text, 1, Len(Text1.Text) - 1)
End If
End Sub
Private Sub CmdC_Click()
s_id = 0
Text1.Text = ""
End Sub
Private Sub CmdCF_Click()
s_id = 1
s = "*"
s1 = Text1.Text
End Sub
Private Sub CmdDY_Click()
If s_id = 2 Then
Select Case s
Case "+"
Text1.Text = s1 + Val(Text1.Text)
s_id = 3
Case "-"
Text1.Text = s1 - Val(Text1.Text)
s_id = 3
Case "*"
Text1.Text = s1 * Val(Text1.Text)
s_id = 3
Case "/"
Text1.Text = s1 / Val(Text1.Text)
s_id = 3
End Select
End If
End Sub
Private Sub CmdJF_Click()
Select Case s_id
Case 0
s = "-"
s1 = Text1.Text
s_id = 1
Case 2
CmdDY_Click
s = "-"
s1 = Text1.Text
s_id = 1
End Select
End Sub
Private Sub CmdP_Click()
If Not p(Text1.Text) Then
Text1.Text = Text1.Text & "."
End If
End Sub
Private Sub CmdSQRT_Click()
Text1.Text = Sqr(Val(Text1.Text))
End Sub
Private Sub CmdX1_Click()
Text1.Text = 1 / Val(Text1.Text)
End Sub
Private Sub CmdZF_Click()
Text1.Text = -Val(Text1.Text)
End Sub
Private Sub Command20_Click()
s_id = 1
s = "/"
s1 = Text1.Text
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 9
C(i).Caption = i
Next i
s_id = 0
End Sub