3个回答
2013-12-07
展开全部
Private Sub Command1_Click(Index As Integer) '0-9数字键
Text1.Text = Text1.Text & Index
Text1.SetFocus
End Sub
Private Sub Command1_KeyPress(Index As Integer, KeyAscii As Integer) '阻止键盘输入,不过不知为什么没有用
KeyAscii = 0
End Sub
Private Sub Command2_Click(Index As Integer) ' "."键
Text1.Text = Text1.Text & "."
End Sub
Private Sub Command3_Click() '退格键
If Text1.Text = "" Then
Exit Sub
End If
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Sub
Private Sub Command4_Click() '清除键
Text1.Text = ""
End Sub
Private Sub Command5_Click(Index As Integer) '做运算,总觉得逻辑上哪有问题
shu1 = Val(Text1.Text)
process = shu1
Text1.Text = ""
If judge = Command5(0) Then
process0 = shu1 + Command(0)
ElseIf judge = Command5(1) Then
process1 = shu1 + Command5(1)
ElseIf judge = Command5(2) Then
process2 = shu1 + Command(2)
ElseIf judge = Command5(3) Then
process3 = shu1 + Command5(3)
End If
shu2 = Val(Text1.Text)
End Sub
Private Sub Command6_Click() '等号
result = process + shu2
Text1.Text = result
If process0 Then
result = shu1 + shu2
ElseIf process1 Then
result = shu1 - shu2
ElseIf process2 Then
result = shu1 * shu2
ElseIf process3 Then
result = shu1 / shu2
End If
End Sub
Private Sub Text1_Change()
If judge = False Then
shu2 = Val(Text1.Text)
End If
Text1.SetFocus
End Sub
Text1.Text = Text1.Text & Index
Text1.SetFocus
End Sub
Private Sub Command1_KeyPress(Index As Integer, KeyAscii As Integer) '阻止键盘输入,不过不知为什么没有用
KeyAscii = 0
End Sub
Private Sub Command2_Click(Index As Integer) ' "."键
Text1.Text = Text1.Text & "."
End Sub
Private Sub Command3_Click() '退格键
If Text1.Text = "" Then
Exit Sub
End If
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Sub
Private Sub Command4_Click() '清除键
Text1.Text = ""
End Sub
Private Sub Command5_Click(Index As Integer) '做运算,总觉得逻辑上哪有问题
shu1 = Val(Text1.Text)
process = shu1
Text1.Text = ""
If judge = Command5(0) Then
process0 = shu1 + Command(0)
ElseIf judge = Command5(1) Then
process1 = shu1 + Command5(1)
ElseIf judge = Command5(2) Then
process2 = shu1 + Command(2)
ElseIf judge = Command5(3) Then
process3 = shu1 + Command5(3)
End If
shu2 = Val(Text1.Text)
End Sub
Private Sub Command6_Click() '等号
result = process + shu2
Text1.Text = result
If process0 Then
result = shu1 + shu2
ElseIf process1 Then
result = shu1 - shu2
ElseIf process2 Then
result = shu1 * shu2
ElseIf process3 Then
result = shu1 / shu2
End If
End Sub
Private Sub Text1_Change()
If judge = False Then
shu2 = Val(Text1.Text)
End If
Text1.SetFocus
End Sub
AiPPT
2024-09-19 广告
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图...
点击进入详情页
本回答由AiPPT提供
2013-12-07
展开全部
这个如何,够简单吧,我自己设计的
Option Explicit
Private Sub Form_Load()
Label1.Caption = ""
End Sub
Private Sub Command1_Click() ' 加法
Label1.Caption = "+"
Text3 = Str$(Val(Text1) + Val(Text2))
End Sub
Private Sub Command2_Click() ' 减法
Label1.Caption = "-"
Text3 = Str$(Val(Text1) - Val(Text2))
End Sub
Private Sub Command3_Click() ' 乘法
Label1.Caption = "×"
Text3 = Str$(Val(Text1) * Val(Text2))
End Sub
Private Sub Command4_Click() ' 除法
Label1.Caption = "÷"
Text3 = Str$(Val(Text1) / Val(Text2))
End Sub
Private Sub Command5_Click() ' 清除
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label1.Caption = ""
End Sub
Option Explicit
Private Sub Form_Load()
Label1.Caption = ""
End Sub
Private Sub Command1_Click() ' 加法
Label1.Caption = "+"
Text3 = Str$(Val(Text1) + Val(Text2))
End Sub
Private Sub Command2_Click() ' 减法
Label1.Caption = "-"
Text3 = Str$(Val(Text1) - Val(Text2))
End Sub
Private Sub Command3_Click() ' 乘法
Label1.Caption = "×"
Text3 = Str$(Val(Text1) * Val(Text2))
End Sub
Private Sub Command4_Click() ' 除法
Label1.Caption = "÷"
Text3 = Str$(Val(Text1) / Val(Text2))
End Sub
Private Sub Command5_Click() ' 清除
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label1.Caption = ""
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-12-07
展开全部
Public Status, Status2 As Integer, tmp, tmp2, k As Single
Private Sub Command1_Click(Index As Integer)
If Text1 = "0" Then Text1 = ""
Dim i, j As Integer
Select Case Index
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
If k = 0 And Status2 = 1 Then tmp = Text1
If k = 0 Then
Text1 = ""
k = k + 1
End If
Text1.SetFocus
SendKeys Index, True
If Status = 0 Then tmp = Text1
If Status2 = 1 Then tmp2 = Text1
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Case 10
For i = 1 To Len(Text1)
If Mid(Text1, i, 1) = "." Then j = j + 1
Next i
If j = 0 Then
Text1.SetFocus
SendKeys ".", True
End If
Case 11
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 0
SetStatus
Status = 1
Status2 = 1
Case 12
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 0
SetStatus
Status = 2
Status2 = 1
Case 13
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 1
SetStatus
Status = 3
Status2 = 1
Case 14
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 1
SetStatus
Status = 4
Status2 = 1
Case 15
If Status <> 0 And Status2 = 0 Then tmp = Text1
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
Text1 = Val(Text1)
Status2 = 0
Case 16
Text1 = Val("")
tmp = 0
tmp2 = 0
Status = 0
Status2 = 0
End Select
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 9
Command1(i).Caption = i
Next i
Text1 = Val(Text1)
End Sub
Private Sub SetStatus()
Status = 0
k = 0
End Sub
Private Sub Ans()
Select Case Status
Case 0
Exit Sub
Case 1
Text1 = Val(tmp) + tmp2
Case 2
Text1 = Val(tmp) - tmp2
Case 3
Text1 = Val(tmp) * tmp2
Case 4
If Val(Text1) = 0 Then Exit Sub
Text1 = Val(tmp) / tmp2
End Select
End Sub
'以上本人原创
Private Sub Command1_Click(Index As Integer)
If Text1 = "0" Then Text1 = ""
Dim i, j As Integer
Select Case Index
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
If k = 0 And Status2 = 1 Then tmp = Text1
If k = 0 Then
Text1 = ""
k = k + 1
End If
Text1.SetFocus
SendKeys Index, True
If Status = 0 Then tmp = Text1
If Status2 = 1 Then tmp2 = Text1
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Case 10
For i = 1 To Len(Text1)
If Mid(Text1, i, 1) = "." Then j = j + 1
Next i
If j = 0 Then
Text1.SetFocus
SendKeys ".", True
End If
Case 11
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 0
SetStatus
Status = 1
Status2 = 1
Case 12
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 0
SetStatus
Status = 2
Status2 = 1
Case 13
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 1
SetStatus
Status = 3
Status2 = 1
Case 14
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
tmp = Text1
tmp2 = 1
SetStatus
Status = 4
Status2 = 1
Case 15
If Status <> 0 And Status2 = 0 Then tmp = Text1
'PB by Jackiejor tmp; tmp2; Status; Status2; vbCrLf
Ans
Text1 = Val(Text1)
Status2 = 0
Case 16
Text1 = Val("")
tmp = 0
tmp2 = 0
Status = 0
Status2 = 0
End Select
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 0 To 9
Command1(i).Caption = i
Next i
Text1 = Val(Text1)
End Sub
Private Sub SetStatus()
Status = 0
k = 0
End Sub
Private Sub Ans()
Select Case Status
Case 0
Exit Sub
Case 1
Text1 = Val(tmp) + tmp2
Case 2
Text1 = Val(tmp) - tmp2
Case 3
Text1 = Val(tmp) * tmp2
Case 4
If Val(Text1) = 0 Then Exit Sub
Text1 = Val(tmp) / tmp2
End Select
End Sub
'以上本人原创
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询