VB编程!请问有谁会VB编程,请
我这有一个简单的计算器代码,只能加减乘除。
觉得合适就给点分。
Option Explicit
Dim flg As Boolean, op As Integer, first As Single
Private Sub Command1_Click(Index As Integer)
If Index = 10 Then
Text1。 Text = Text1。Text & "。"
Else
Text1。Text = Text1。Text & CStr(Index)
End If
If Len(Text1) = 2 And Left(Text1, 1) = "0" And Mid(Te...全部
我这有一个简单的计算器代码,只能加减乘除。
觉得合适就给点分。
Option Explicit
Dim flg As Boolean, op As Integer, first As Single
Private Sub Command1_Click(Index As Integer)
If Index = 10 Then
Text1。
Text = Text1。Text & "。"
Else
Text1。Text = Text1。Text & CStr(Index)
End If
If Len(Text1) = 2 And Left(Text1, 1) = "0" And Mid(Text1, 2) <> "。
" Then
Text1 = Mid(Text1, 2)
End If
End Sub
Private Sub command2_click(Index As Integer)
first = Val(Text1。
Text)
op = Index
Text1。Text = ""
End Sub
Private Sub command3_click()
Text1。Text = ""
End Sub
Private Sub Command4_Click()
Dim sec As Single
sec = Val(Text1。
Text)
Select Case op
Case 0
Text1。Text = Str(first + sec)
Case 1
Text1。
Text = Str(first - sec)
Case 2
Text1。Text = Str(first * sec)
Case 3
If sec <> 0 Then
Text1。
Text = Str(first / sec)
Else
Text1。Text = "除数为0"
End If
Case 4
If sec <> 0 Then
Text1。
Text = Str(first Mod sec)
Else
Text1。Text = "除数为0"
End If
End Select
End Sub
Private Sub Command5_Click()
End
End Sub
Private Sub Command6_Click()
Dim a, b As String
a = Left(Text1, 1)
If a <> "-" Then
Text1。
Text = "-" & Text1。Text
Else
b = Mid(Text1, 2, Len(Text1) - 1)
Text1。Text = b
End If
End Sub
。
收起