先从小工具入手,慢慢学习,最终目标能编写一个自己工作需要的软件
[Visual Basic] 纯文本查看 复制代码 Dim a, b, c As Double
Dim x, y As Double
Private Sub Command1_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a + b
Text3.Text = c
Print "A+B=" & c
End Sub
Private Sub Command10_Click()
x = Val(Text4.Text)
e = Exp(1)
y = Log(x) / Log(e)
Text3.Text = y
Print "ln" & x; "=" & y
End Sub
Private Sub Command11_Click()
x = Val(Text4.Text)
y = Sin(x)
Text3.Text = y
Print "sin" & x; "值为" & y
End Sub
Private Sub Command12_Click()
x = Val(Text4.Text)
y = Cos(x)
Text3.Text = y
Print "cos" & x; "值为" & y
End Sub
Private Sub Command13_Click()
x = Val(Text4.Text)
y = Tan(x)
Text3.Text = y
Print "tan" & x; "值为" & y
End Sub
Private Sub Command14_Click()
x = Val(Text4.Text)
y = Atn(x)
Text3.Text = y
Print "cot" & x; "值为" & y
End Sub
Private Sub Command15_Click()
Form1.Cls
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
Private Sub Command2_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a - b
Text3.Text = c
Print "A-B=" & c
End Sub
Private Sub Command3_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a * b
Text3.Text = c
Print "A*B=" & c
End Sub
Private Sub Command4_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
If b = 0 Then
MsgBox "被除数不能为0"
Else
c = a / b
Text3.Text = c
Print "A/B=" & c
End If
End Sub
Private Sub Command5_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a ^ b
Text3.Text = c
Print "A^B=" & c
End Sub
Private Sub Command6_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a ^ (1 / b)
Text3.Text = c
Print "A的B次方根=" & c
End Sub
Private Sub Command7_Click()
MsgBox "现在时间为:" & Now()
End Sub
Private Sub Command8_Click()
a = Val(Text1.Text)
b = Val(Text2.Text)
If a > 0 And a <> 1 And b > 0 Then
c = Log(b) / Log(a)
Text3.Text = c
Print "logAB=" & c
Else
MsgBox "对数底A应大于0且不等于1,或者B>0"
End If
End Sub
Private Sub Command9_Click()
x = Val(Text4.Text)
y = Log(x) / Log(10)
Text3.Text = y
Print "lg" & x; "=" & y
End Sub
|