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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch when calling subroutine

Status
Not open for further replies.

jmischo

Programmer
Dec 15, 2004
2
US
I'm having a lot of trouble getting my VBS to do what I want it to. I can't seem to figure out how to a) register a class that resides in a file, b) call a sub that resides in a file, or c) not go nuts.

Yes, it's driving me nuts. addToQueue is defined in pcontrol.vbs as a Sub. Originally it was in a class in that file, but I couldn't figure out how to instantiate a class from a file, so I just put the subs in the file.

Below is a snippet of code (names changed to protect the innocent, and my job...). When it actually calls addToQueue, it gives me a Type Mismatch error that refers to the first character of the function name.



<SCRIPT language=VBScript src="pcontrol.vbs"></SCRIPT>
<SCRIPT language=vbscript event=onclick for=btnAddToQueue>
<!--
Dim myFields
Dim tmpMSG
Dim myMSG
Dim myP
Dim myR
Dim myA
Dim msgRET

Set myFields = MSODSC.CurrentSection.DataPage.Recordset.Fields

myP = myFields.Item("PN").value
myR = myFields.Item("RN").value
myA = myFields.Item("AN").value

myMSG = "PID: " & Left(myP, 4) & " RID: " & myR & " AID: " & myA
msgRET = MsgBox(myMSG, 65, "Adding to queue")
if msgRET = 1 Then
addToQueue Left(myP, 4), myR, myA
else
MsgBox "Aborted.", 48, "Add to Queue"
End If
-->
</SCRIPT>
 
I partially resolved this by moving the code into a SCRIPT block on the page. It's not a permanent solution, but it allowed me to discover that there were bugs in the subs that made up the former class. Such is the joy of porting VBA to VBS.

I'm still having problems, but they're mainly due to APIs not working the way documentation and code samples lead me to expect them to.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top