Forum Discussion

joe_2's avatar
joe_2
Contributor
10 years ago

Silly question of the day: Subroutines with subroutines

So I tried to do something and it didn't work, and I googled it and found it didn't work because vbscript can't do that... I was trying to put a subroutine within a subroutine.   I have a script. ...
  • amarr1143l's avatar
    10 years ago

    If I understand your situation correctly, you can use Class-Sub instead of Sub-Sub. 

     

    Give it a try:

     

    In Unit1:

     

    Class ClsProperty
    Sub propertyName(strContent)
    msgbox strContent
    end Sub
    End Class

    Sub MySub(strContent)
    set obj = new ClsProperty
    obj.propertyName(strContent)
    End sub

     

    In Unit2:

     

    'USEUNIT Unit1

    sub Callee
    Unit1.MySub("test")
    End Sub