在VB中如何执行变量中的内容?
dim str as string
str="frm.show"    'frm是窗体请问各位:如何才能将str中的内容替换出来执行?万分的感谢!

解决方案 »

  1.   

    假设你要显示的窗体是Form2,首先在Form2中加入下面的代码:Public Sub showme()
        Me.Show
    End Sub然后在工程中引用Microsoft Script Control ,然后在主窗体中添加commandbutton,在其中加入以下代码:Private Sub Command1_Click()
        Dim x As New ScriptControl
        Dim c As New Class1
        Dim frm As New Form2
        
        x.Language = "VBScript"
        x.AllowUI = True
        x.AddObject "frm", frm
        x.Eval "frm.showme"
    End Sub
      

  2.   

    参考:http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q185/6/97.asp&NoWebContent=1