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

后端 未结 3 1643
庸人自扰
庸人自扰 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:03

    Option Explicit 
    
    function abc(a)
      MsgBox a
    End function
    
    dim run : run = "abc ""Hallo"""
    execute run
    

    The execute method can do this


    Public Function sayhi
    
    msgbox "hi"
    
    end
    
    Dim level0
    
    dim count1
     count1 = DataTable.GetSheet("Action1").GetRowCount
    msgBox  count1
    
    For counterVariable = 1 to count1
        functionname = "call " &  DataTable.value("methodnames","Action1")
        execute functionname
        DataTable.GetSheet("Action1").SetCurrentRow(counterVariable)
    Next
    

    will call sayhi if its in the datatable.

提交回复
热议问题