Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



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

Posts: 8
Trades: 0
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
 
 
Register now for full access!
Old 10-19-2004, 04:08 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
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 04:13 PM..
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 10-19-2004, 04:20 PM
Novice Talker

Posts: 8
Trades: 0
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, 04:23 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
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
 
Old 10-19-2004, 04:29 PM
Novice Talker

Posts: 8
Trades: 0
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, 04:41 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
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-20-2004 at 12:14 AM..
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 10-19-2004, 04:45 PM
Novice Talker

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

Posts: 8
Trades: 0
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-20-2004, 12:14 AM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
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
 
Reply     « Reply to Type mismatch error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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 1.10432 seconds with 12 queries