Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem passing variables between Subs

Status
Not open for further replies.

dgr7

IS-IT--Management
Joined
Dec 29, 2006
Messages
43
Location
US
hello,

I'm trying to pass two Variant variables between two Subroutines, one that calls the other one, and am getting the error message
Run-time error '5':

Invalid procedure call or assignment

and the code stops on
AppActivate CablettersAppId

Code:
Private Sub ForTestingPurposes_Click()
Dim CablettersAppId, CabcallsAppId As Variant

    CablettersAppId = Shell("C:\Program Files\Anzio15\anzio32.exe", 1)
    CabcallsAppId = Shell("D:\PROGRAM FILES\TELSTAR\TelStar.exe", 1)

    Call CABCALLSandCABLETTERStestTelnet(CabletttersAppId, CabcallsAppId)
    
    Status.Text = "end of test"
End Sub
    

Private Sub CABCALLSandCABLETTERStestTelnet(CablettersAppId, CabcallsAppId)

    TimeDelay (7)
    AppActivate CablettersAppId
    VbSendKeys "robinson{ENTER}"
    TimeDelay (2)
    VbSendKeys "CAB{ENTER}"
    TimeDelay (2)
    VbSendKeys "DR75{ENTER}"
    TimeDelay (2)
    VbSendKeys "{ENTER}"

    TimeDelay (60 * 5)

    TimeDelay (7)
    AppActivate CabcallsAppId
    VbSendKeys "robinson{ENTER}"
    TimeDelay (2)
    VbSendKeys "ROPER{ENTER}"
    TimeDelay (2)
    VbSendKeys "DR75{ENTER}"
    TimeDelay (2)
    VbSendKeys "{ENTER}"
    TimeDelay (2)
End Sub


Now this code use to work before when I had it all contained within one Sub like this:

Code:
Private Sub ForTestingPurposes_Click()
Dim CablettersAppId, CabcallsAppId As Variant

    CablettersAppId = Shell("C:\Program Files\Anzio15\anzio32.exe", 1)
    CabcallsAppId = Shell("D:\PROGRAM FILES\TELSTAR\TelStar.exe", 1)
    
    TimeDelay (7)
    AppActivate CablettersAppId
    VbSendKeys "robinson{ENTER}"
    TimeDelay (2)
    VbSendKeys "CAB{ENTER}"
    TimeDelay (2)
    VbSendKeys "DR75{ENTER}"
    TimeDelay (2)
    VbSendKeys "{ENTER}"

    TimeDelay (60 * 5)

    TimeDelay (7)
    AppActivate CabcallsAppId
    VbSendKeys "robinson{ENTER}"
    TimeDelay (2)
    VbSendKeys "ROPER{ENTER}"
    TimeDelay (2)
    VbSendKeys "DR75{ENTER}"
    TimeDelay (2)
    VbSendKeys "{ENTER}"
    TimeDelay (2)
    Status.Text = "end of test"
End Sub


Can anyone help me to get it to work in a multi-subroutine/function setting?

thanks in advance,
david
 
You have three "t"s in the call statement

If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
And Option Explicit would have picked that up for you ...
 
:) Oops...that's embarassing.

That fixed the problem, thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top