Is it possible to call a function whose name is stored in a string in vbscript?

后端 未结 3 1642
庸人自扰
庸人自扰 2020-12-06 08:39

i am trying to write a script in qtp like this

Public Function sayhi

msgbox \"hi\"

end

Dim level0

dim count1
 count1 = DataTable.GetSheet(\"Action1\").Ge         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-06 09:19

    Someone mentioned there was no Include in VBS but you can code one with...

    Sub Include(yourFile)
      Dim oFSO, oFileBeingReadIn   ' define Objects
      Dim sFileContents            ' define Strings
    
      Set oFSO = CreateObject("Scripting.FileSystemObject")
      Set oFileBeingReadIn = oFSO.OpenTextFile(yourFile & ".vbs", 1)
      sFileContents = oFileBeingReadIn.ReadAll
      oFileBeingReadIn.Close
      ExecuteGlobal sFileContents
    End Sub
    

    My source : http://cyreath.blogspot.com/2014/02/vbscript-call-function-in-another-file.html

提交回复
热议问题