Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 CInt() problem
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

es4725
Junior Member

205 Posts

Posted - 01 March 2002 :  12:15:36  Show Profile
I'm unable to use CInt() for a string -> number conversion, the number is 9 digits long, so I don't recall which conversion should be used. I've tried several, and none seem to work. can anyone help?



Edited by - es4725 on 04 March 2002 17:35:11

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 01 March 2002 :  12:43:36  Show Profile
Did you try CLng()?

Nikkol
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 02 March 2002 :  01:58:16  Show Profile
yep... that's why I didn't understand why it wasn't working...

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 02 March 2002 :  02:09:55  Show Profile
Are you trying to convert a string to a number or a number to a string?

Nikkol
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 02 March 2002 :  03:27:03  Show Profile
string to number

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 02 March 2002 :  04:53:12  Show Profile
What error are you getting?

Nikkol
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 02 March 2002 :  08:21:47  Show Profile
Also Can you post the string you are trying to convert.

www.forumSquare.com - GauravBhabu - It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 04 March 2002 :  17:33:36  Show Profile
ok - I'm an idiot - the problem isn't actually with CInt() - I'm using CLng() and it works fine. The error is actually w/ comparing that value to the DB entry. The DB field is a Number field (access) when trying to compare, I get a Type mismatch error. I don't understand why.

I apologize for my original inaccurate post too by the way...

Edited by - es4725 on 04 March 2002 17:36:26
Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 04 March 2002 :  18:25:32  Show Profile
Is it a Long Integer in Access? What is the comparison statement you are using? Show me the code.

Nikkol
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 04 March 2002 :  18:34:46  Show Profile
Yes it is a Long Integer in access.

Dim iNumber = CLng(Request.Form("Number")
Do Until objRS.EOF or bolFound
If (objRS("Number") = iNumber) Then
'found it
bolFound = True
Else
objRS.MoveNext
End If
Loop

That's basically the code. The error is at the red line

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 04 March 2002 :  18:44:51  Show Profile
First can you Dim a variable and set it on the same line? Try changing the red line first. If that doesn't work, then try making the change indicated to the green line.


iNumber = CLng(Request.Form("Number")
Do Until objRS.EOF or bolFound
If CLng((objRS("Number")) = iNumber Then
'found it
bolFound = True
Else
objRS.MoveNext
End If
Loop


Nikkol

Edited by - Nikkol on 04 March 2002 18:45:49
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 04 March 2002 :  19:05:43  Show Profile
quote:


iNumber = CLng(Request.Form("Number")


Oops - didn't mean to type it in here that way. I don't have it coded that way.
quote:

If CLng((objRS("Number")) = iNumber Then




I'll give that a go... I'll let you know. Thanks

Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 04 March 2002 :  19:12:50  Show Profile
Still not working. I tried converting both to strings as well... still getting a type mismatch...

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 04 March 2002 :  19:16:39  Show Profile
Gosh...that's strange. Are the entries you're pulling from the database from a field that allows Nulls (that may be it)? Or is "Number" the actual name for the field? If so, try changing it to something else like "myNumber" (might have to do with a reserved word).

Nikkol
Go to Top of Page

es4725
Junior Member

205 Posts

Posted - 04 March 2002 :  19:24:29  Show Profile
doesn't allow null... and the whole Number thing wasn't it either... I'm stumped...

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 04 March 2002 :  19:38:17  Show Profile
Just noticed that there wasn't a closing )
iNumber = CLng(Request.Form("Number"))
but I'm sure that was just a typo.

I'm stumped too. Is there a way you could post a link to a text version of the code you're using?

Nikkol
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.38 seconds. Powered By: Snitz Forums 2000 Version 3.4.07