Reply
Type mismatch error
Old 10-19-2004, 03:03 PM Type mismatch error
Novice Talker

Posts: 8
I am getting the following error:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: '[string: "MND3"]'

at the following line of code:
CCID = Right(Request("CourseNumber"),Len(Request("CourseN umber") - 3))

It's a simple problem: as part of a data string I am receiving an identity (CourseNumber) that is either one or two numbers long and is sometimes prefixed by the letters MND
(say MND3 or MND62). I need to strip the MND out and use only the numbers. The code used follows:

If Left(Request("CourseNumber"),3) = "MND" then
CCID = Right(Request("CourseNumber"),Len(Request("CourseN umber") - 3))
Else
CCID = Request("CourseNumber")
End If

The logic seems sound, but I am getting the type mismatch error.

Any ideas how to fix it?
gadfly is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 10-19-2004, 03:08 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
It seems as though you've got your parens in the wrong place.
I've modified your code to put the parens in correctly:
Code:
CCID = Right(Request("CourseNumber"),Len(Request("CourseNumber"))- 3)

Last edited by Anacrusis : 10-19-2004 at 03:13 PM.
Anacrusis is offline
Reply With Quote
View Public Profile Visit Anacrusis's homepage!
 
Old 10-19-2004, 03:20 PM
Novice Talker

Posts: 8
You might be right. In fact I believe you are!
But it still has not fixed the problem. i am still getting the same error.
gadfly is offline
Reply With Quote
View Public Profile
 
Old 10-19-2004, 03:23 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
I'm not seeing anything else wrong with your code.
You're getting the same error on the same line? Did you edit your code exactly as I've posted it?
Anacrusis is offline
Reply With Quote
View Public Profile Visit Anacrusis's homepage!
 
Old 10-19-2004, 03:29 PM
Novice Talker

Posts: 8
Yes, exactly.
I'm wondering if I need to convert the resulting numbers to an integer. If you cut MND3 to 3, it's still a text string, right?
gadfly is offline
Reply With Quote
View Public Profile
 
Old 10-19-2004, 03:41 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
In ASP, everything is treated as a varient. Usually when you get a type mismatch it's because your trying to do math on something that contains something other then numbers.

To answer your question, if you cut MND3 to 3, it's still a varient.
If you add 6 to it, it will be treated as an integer. (3+6).
If you concatanate something to it, it will be a character. ("the number is " & 3)

Try displaying all your variables and see if your getting what you expect. Watch for NULLs as they can be a nusiance.

Try breaking up your code into smaller chunks to see how it works and exactly where it's breaking:
Code:
tmp1 = Request("CourseNumber")
response.write tmp1

tmp2 = Len(Request("CourseNumber"))- 3
response.write tmp2

tmp3 = right(tmp1, tmp2)
response.write tmp3
Hope that helps even a little.

Last edited by Anacrusis : 10-19-2004 at 11:14 PM.
Anacrusis is offline
Reply With Quote
View Public Profile Visit Anacrusis's homepage!
 
Old 10-19-2004, 03:45 PM
Novice Talker

Posts: 8
Thank you. i'll give it a try..
gadfly is offline
Reply With Quote
View Public Profile
 
Old 10-19-2004, 05:59 PM
Novice Talker

Posts: 8
Boy, do I feel like an idiot. Your parens correction actually fixed the problem. But I applied it to a COPY of the code instead of the live code, which was why I kept getting the same error over and over. A five minute walk in the rain fixed my head problem.

Thank you so much for your help!
gadfly is offline
Reply With Quote
View Public Profile
 
Old 10-19-2004, 11:14 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
I'm glad it's working for you now.
It usually is the simple things that get ya. Sometimes just getting away for a bit allows you to come back and see things with a new perspective, allowing you to pick up on things that got overlooked the first time you looked at it.
Anacrusis is offline
Reply With Quote
View Public Profile Visit Anacrusis's homepage!
 
Reply     « Reply to Type mismatch error
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15151 seconds with 13 queries