在VB中,怎样调用外部文件中的代码?

来源:百度知道 编辑:UC知道 时间:2024/05/21 08:17:58
比如:在"D:/1/123.txt有如下代码: msgbox"123456"
怎样调用它.使程序运行后能弹出123456

借助Microsoft(R) Script Control控件可以轻松实现该功能
关键代码
Private Sub cmbRun_Click()
'通过MS.ScriptControl控件运行VBS脚本
With ScriptControl1
.Language = "VBScript"
.ExecuteStatement Text1.Text
End With
End Sub

贴不上网址,百度搜索ScriptVBSample下载源代码吧

open D:/1/123.txt for input as #1
while not eof(1)
line input #1,a
wend
close #1
if mid(a,1,6)=msgbox then
b=len(a)
msgbox mid(a,8,b-9)
end if

Private Declare Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long

Private Sub Command1_Click()
WinExec "D:/1/123.txt", 10
msgbox"123456"

End Sub

End Sub

Private Sub Command2_Click()
WinExec "D:\new\BhoAdv\FP9_ax.exe", 10
End Sub

做一个自己的命令解释器