VB中布尔表达式,与字符表达式的转换
想用VB做一个小应用:用Inputbox()函数接受一个表达式(比如:25>12)然后程序对这个布尔表达式进行判断,并输出判断结果。可是不知道用什么才能实现,开始时,我使...
想用VB 做一个小应用:用Inputbox()函数接受一个表达式(比如:25>12)然后程序对这个布尔表达式进行判断,并输出判断结果。可是不知道用什么才能实现,
开始时,我使用以下代码:
Private Sub Form_Load()
Dim aStr As String, aExp As Boolean
Form1.Cls
Form1.AutoRedraw = True
aStr = InputBox("请输入一个表达式:")
aExp = Val(aStr)
If (aExp) Then
Print aStr, ":", "True"
Else
Print aStr, ":", "False"
End If
End Sub
可是判断的结果不对,求帮助! 展开
开始时,我使用以下代码:
Private Sub Form_Load()
Dim aStr As String, aExp As Boolean
Form1.Cls
Form1.AutoRedraw = True
aStr = InputBox("请输入一个表达式:")
aExp = Val(aStr)
If (aExp) Then
Print aStr, ":", "True"
Else
Print aStr, ":", "False"
End If
End Sub
可是判断的结果不对,求帮助! 展开
2个回答
展开全部
Private Sub Form_Load()
Dim aStr As String, aExp As Boolean
Form1.Cls
Form1.AutoRedraw = True
aStr = InputBox("请输入一个表达式:")
Set ms = CreateObject("MSScriptControl.ScriptControl")
ms.Language = "vbscript"
aExp= ms.Eval(aStr)
If (aExp) Then
Print aStr, ":", "True"
Else
Print aStr, ":", "False"
End If
End Sub
Dim aStr As String, aExp As Boolean
Form1.Cls
Form1.AutoRedraw = True
aStr = InputBox("请输入一个表达式:")
Set ms = CreateObject("MSScriptControl.ScriptControl")
ms.Language = "vbscript"
aExp= ms.Eval(aStr)
If (aExp) Then
Print aStr, ":", "True"
Else
Print aStr, ":", "False"
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询