INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Type mismatch error that makes no sense

Type mismatch error that makes no sense

(OP)
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

RE: Type mismatch error that makes no sense

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.

RE: Type mismatch error that makes no sense

(OP)
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

RE: Type mismatch error that makes no sense

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

CODE

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


Also, shouldn't "<br" be "<br>"?

RE: Type mismatch error that makes no sense

(OP)
Got it, thanks! And yes, it appears that it should be.

wb

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close