1 / 12
文档名称:

VB语言编程.doc

格式:doc   大小:35KB   页数:12页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

VB语言编程.doc

上传人:1314042**** 2021/2/23 文件大小:35 KB

下载得到文件列表

VB语言编程.doc

文档介绍

文档介绍:简单运算(计算)
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