文档介绍:简单运算(计算)
Dim opt As String
Private Sub Command1_Click()
opt = "+"
End Sub
Private Sub Command2_Click()
opt = "-"
End Sub
Private Sub Command3_Click()
opt = "*"
End Sub
Private Sub Command4_Click()
opt = "/"
End Sub
Private Sub Command5_Click()
Dim a, b, result As Double
a = Text1Text
b = Text2Text
Select Case opt
Case "+"
result = Val(a) + Val(b)
Case "-"
result = Val(a) - Val(b)
Case "*"
result = Val(a) * Val(b)
Case "/"
result = Val(a) / Val(b)
End Select
Text3Text = result
End Sub
存放字符
Private Sub Command1_Click()
Dim ch As String * 1
ch = InputBox("输入")
If UCase(ch) >= "A" And UCase(ch) <= "z" Then
MsgBox (ch + "是字符字母")
ElseIf ch >= "0" And ch <= "9" Then
MsgBox (ch + "是数字")
Else
MsgBox (ch + "是其他字符")
End If
End Sub
简单比较
Private Sub Command1_Click()
Dim a, b As Double
a = Text1Text
b = Text2Text
If a > b Then
MsgBox "a大于b"
ElseIf b > a Then
MsgBox "b大于a"
ElseIf b = a Then
MsgBox "a等于b"
End If
End Sub
字符串运算
Private Sub Command1_Click()
Dim a As String
a = Text1Text
Print "你在文本框中输入的是:" & a
End Sub
常用内部函数
im a As Double
Private Sub Command1_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Fix(a)
End Sub
Private Sub Command2_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Abs(a)
End Sub
Private Sub Command3_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Sgn(a)
End Sub
Private Sub Command4_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Int(a)
End Sub
Private Sub Command5_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Sqr(a)
End Sub
Log Sin 等函数的运用
Dim a As Integer
Private Sub Command1_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Log(a)
End Sub
Private Sub Command2_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Sin(a)
End Sub
Private Sub Command3_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Cos(a)
End Sub
Private Sub Command4_Click()
a = Val(Text1Text)
MsgBox "函数值为:" & Tan(a)
End Sub
Private Sub Command5_Click()
a