Private Declare Function EbExecuteLine Lib "vba6.dll" (ByVal pStringToExec As Long, ByVal Unknownn1 As Long, ByVal Unknownn2 As Long, ByVal fCheckOnly As Long) As Long
Public Function ExecuteLine(sCode As String, Optional fCheckOnly As Boolean) As Boolean
ExecuteLine = EbExecuteLine(StrPtr(sCode), 0&, 0&, Abs(fCheckOnly)) = 0
End Function
'传入的参数:strFormName为窗体类型名称
Public Function ShowForm(ByVal strFormName As String)
ExecuteLine "Dim fForm1 As " & strFormName
ExecuteLine "set fForm1 = new " & strFormName
ExecuteLine "fForm1.Show " '显示窗体
' ExecuteLine "Unload fForm1" '卸载窗体
End Function
Private Sub Command1_Click()
Dim f As String
f = "Form2"
Call ShowForm(f)
End Sub