Question

i am facing a vb script run time error saying "wrong number of arguments or invalid property assignment". 'useunit sub in unita call unita.testsub(param1,param2) end sub

'sub in unitb sub testsub(param1,param2) ..... end sub

Was it helpful?

Solution

After USEUNIT you need to specify the name of the unit whose functions you will use in this unit. So, change your code in the following way:

unita

'USEUNIT unitb
sub main
  dim param1
  dim param2
  param1="Test"
  param2="Complete"
  call unitb.testsub(param1,param2)
end sub

unitb

sub testsub(param1,param2)
  Log.Message(param1 & param2)
end sub

OTHER TIPS

I believe that

call unita.testsub(param1,param2)

should be

call unitb.testsub(param1,param2)

i found this from the oficial forums Execute "Call UnitName.SubWithParams(1, ""string"", True)" ' Using syntax with the Call keyword and parentheses

Execute "UnitName.SubWithParams 1, ""string"", True" ' Syntax without the Call keyword and parentheses

res = Eval("UnitName.FunctionWithParams(1, ""string"", True)")

' Inserting parameter values dynamically

strFunctionCall = aqString.Format("UnitName.FunctionWithParams(%d, ""%s"", %s)", 42, "string", CStr(True))

res = Eval(strFunctionCall)

but still donot know how exactly should we pass the parameters

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top