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

Type mismatch error that makes no sense 1

Status
Not open for further replies.

wbodger

Programmer
Apr 23, 2007
769
US
In my code I have this

Code:
strResponse="We are very sorry for this inconvenience, but your electronic donation did not go thru. However, we greatly appreciate your desire to contribute to our ministry here at Youth Conference Ministries. Please contact us at (423)624-2495 and we will handle your donation with a personal touch."
  Response.Write "The operation failed with the following errors:<br>" & vbCrLf
  PrintErrors(objResponse)

which works fine, but does not display as I would like. So, I tried adding the response.write and the PrintErrors(objResponse) into the strResponse variable

Code:
strResponse="We are very sorry for this inconvenience, but your electronic donation did not go thru. However, we greatly appreciate your desire to contribute to our ministry here at Youth Conference Ministries. Please contact us at (423)624-2495 and we will handle your donation with a personal touch. The operation failed with the following errors:<br>" 
strResponse = strResponse & PrintErrors(objResponse)

which gives me the error

Code:
Microsoft VBScript runtime error '800a000d'

Type mismatch: 'PrintErrors'

/secure/give/sendarbtoan.asp, line 75

where line 75 is strResponse = strResponse & PrintErrors(objResponse)

Now, it is late and I am very tired. Anybody see what I am missing?

wb
 
Hi wb,

is PrintErrors a function or a sub?
if it is a sub, you cannot add it to a string.
If it is a function with string result, you might want to add one intermediate step:
Code:
res=PrintErrors(objResponse)
strResponse = strResponse & res

Good luck!
MakeItSo

“Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family.” (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Ahh... found it. It is a sub

Code:
Sub PrintErrors(objResponse)
  Dim objMessages, objMsg
  set objMessages = objResponse.selectNodes("/*/api:messages/api:message")
  For Each objMsg in objMessages
    Response.Write "[" & Server.HTMLEncode(objMsg.selectSingleNode("api:code").Text) & "] " _
      & Server.HTMLEncode(objMsg.selectSingleNode("api:text").Text) & "<br" & vbCrLf
  Next
  Response.Write "<br>" & vbCrLf
End Sub

Could I turn this into a function and then return it as an object that I could add to a variable?

wb
 
This function will return a string, as opposed to your sub, which wrote to the response object directly.

Code:
[highlight #FCE94F]Function[/highlight] PrintErrors(objResponse)
   Dim objMessages, objMsg
   set objMessages = objResponse.selectNodes("/*/api:messages/api:message")
   For Each objMsg in objMessages
      [highlight #FCE94F]PrintErrors = PrintErrors &[/highlight] "[" & Server.HTMLEncode(objMsg.selectSingleNode("api:code").Text) & "] " _
         & Server.HTMLEncode(objMsg.selectSingleNode("api:text").Text) & "<br" & vbCrLf
   Next
   [highlight #FCE94F]PrintErrors = PrintErrors &[/highlight] "<br>" & vbCrLf
End [highlight #FCE94F]Function[/highlight]


Also, shouldn't "<br" be "<br>"?
 
Got it, thanks! And yes, it appears that it should be.

wb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top