CDbl() will convert the string to a numeric.
Fritz the Blank
Main Topics
Browse All TopicsI'm trying to create a serialized identification string, where the first 4 characters are letters and the last 5 characters are numbers. To create a new ID, I get the maximum ID string from the database, extract the final 5 characters (which are in the form 00001, 00002, etc.), convert them to a number, add 1, and re-build a 9-character string using the new number. My problem lies in converting the characters to a number; val() doesn't work and cint() requires a number input (I've tried it here and it doesn't work). Is there a way to convert a string to a number value in VB Script?
Here's my code:
strSQL = "Select max(ID) as Alumni_ID from RUNNERS.Ath_Profile where ID like " & CHR(39) & "Alum%" & CHR(39)
Set AlumData = nothing
Set AlumData = Currdb.CreateDynaset(strSQ
AlumData.MoveFirst
MaxAlumID = AlumData.Fields("Alumni_ID
If IsNull(MaxAlumID) Then
AlumSeqNum = 1 'This covers the first record inserted to the database
Else
AlumSeqNum = Val(Right(CStr(MaxAlumID))
End If
vAlumSerial = "0000" & Trim(CStr(AlumSeqNum))
vAlumSSO = "Alum" & Right(vAlumSerial, 5) 'Re-build ID string with new serial number
Any help would be greatly appreciated, thanks!
mckenzma
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: fritz_the_blankPosted on 2003-05-08 at 11:29:49ID: 8490894
CInt() will convert the string to an integer.
Fritz the Blank