vb 简单运算代码
来源:百度知道 编辑:UC知道 时间:2024/05/31 08:47:38
看完这段代码 我想知道 dim后边的变量都是什么
Option Explicit
Dim bolFlagPoint As Boolean, bolFlagSign As Boolean
Dim strCalc As String, strSign As String
Dim objEval As New ScriptControl
Private Sub cmdCheng_Click()
strSign = "*"
If strCalc = "" Then
strCalc = txtView.Text & strSign
Else
strCalc = strCalc & txtView.Text & strSign
End If
bolFlagSign = True
bolFlagPoint = False
End Sub
Private Sub cmdChu_Click()
strSign = "/"
If strCalc = "" Then
strCalc = txtView.Text & strSign
Else
strCalc = strCalc & txtView.Text & strSign
End If
bolFlagSign = True
bolFlagPoint = False
End Sub
Private Sub cmdDeng_Click()
strCalc = strCalc & txtView.Text
txtView.Text = objEval.Eval(strCalc)
End Sub
Option Explicit
Dim bolFlagPoint As Boolean, bolFlagSign As Boolean
Dim strCalc As String, strSign As String
Dim objEval As New ScriptControl
Private Sub cmdCheng_Click()
strSign = "*"
If strCalc = "" Then
strCalc = txtView.Text & strSign
Else
strCalc = strCalc & txtView.Text & strSign
End If
bolFlagSign = True
bolFlagPoint = False
End Sub
Private Sub cmdChu_Click()
strSign = "/"
If strCalc = "" Then
strCalc = txtView.Text & strSign
Else
strCalc = strCalc & txtView.Text & strSign
End If
bolFlagSign = True
bolFlagPoint = False
End Sub
Private Sub cmdDeng_Click()
strCalc = strCalc & txtView.Text
txtView.Text = objEval.Eval(strCalc)
End Sub
Dim bolFlagPoint As Boolean, bolFlagSign As Boolean
Dim strCalc As String, strSign As String
Dim objEval As New ScriptControl
一般情况下变量命名都会有约定俗成的命名规则:类型简写+变量名
如:bolFlagPoint,说明了它是布尔型变量
strCalc,说明它是字符型变量
objEval,说明它是一个对象变量,obj是object的简写,ScriptControl是要定义的对象类型
又如:dim frmSearch as Froms 说明它是一个窗体
dim 后面的变量为bolFlagPoint , bolFlagSign ,strCalc ,strSign ,objEval