第1个回答 2011-11-29
RunAs "sub1"
RunAs "sub2"
Sub sub1
MsgBox "code1"
End Sub
Sub sub2()
MsgBox "code2"
End Sub
Sub RunAs(Byval e)
'Author:次碳酸钴
Dim txt,match,path,file,myname
myname=WScript.ScriptName
With CreateObject("Scripting.FileSystemObject")
path=.GetSpecialFolder(2)&"\"&e&myname
txt=.OpenTextFile(myname).ReadAll
With New RegExp
.Pattern="sub\s+"&e&"(?:\(\s*\))?([\s\S]+?)end\s+sub"
.IgnoreCase=True
Set match=.Execute(txt)(0)
End With
.OpenTextFile(path,2,1).Write match.SubMatches(0)
CreateObject("WScript.Shell").Run path
End With
End Sub本回答被提问者采纳