我有一个从文件中读取的字符串:“a1=20 and a2=qq”,想把它作为程序中if语句的条件,该怎么实现?
 首先将字符串赋值给一变量
dim Strww as string 
Strww =“a1=20 and a2=qq”if Strww then
  msgbox"成功!"
end if但是这个strww通不过调试,该怎么处理,请高手指点。谢谢!

解决方案 »

  1.   

    Dim Strww As String
    If Strww = "a1=20 and a2=qq" Then
      MsgBox "成功!"
    End If
      

  2.   

    Private Sub Command1_Click()
    Dim a1 As String, a2 As String
    a1 = "30": a2 = "qq"If a1 = "20" And a2 = "qq" Then
      MsgBox "成功!"
      Else
      MsgBox "不成功 "
    End IfEnd Sub
      

  3.   

    用 Microsoft Script Control 1.0 控件
    Option ExplicitPrivate Sub Command1_Click()
        ScriptControl1.Language = "VBScript"
        ScriptControl1.Reset
        ScriptControl1.AddCode "a1=20" & vbCrLf & _
                               "a2=3" & vbCrLf & _
                               "qq=3"
        If ScriptControl1.Eval("a1=20 and a2=qq") Then
            MsgBox "成功!"
        End If
    End Sub
      

  4.   

    如果逻辑表达式不太复杂也可以用很多if或select case语句识别语法后解释执行
      

  5.   

    用vbscript的execute 执行一下字符串就可了
      

  6.   

    Strww 是从文件读取出来的一个字符串