What is the equivalent of the strtoul routine in VB?

I am porting a routine from C to VB and have everything done except I need a way of simulating the C strtoul routine. This routine converts a string to an unsigned long.

I've done quite a bit in VB but this is over my head.
mnorma12Asked:
Who is Participating?
 
Mikal613Connect With a Mentor Commented:
ZoneNumber=LongToUnsigned(Clng(Val(UTMZone)))
0
 
Mikal613Commented:
LongToUnsigned(clng(yourval))
0
 
Mikal613Commented:
or

LongToUnsigned(clng(val(yourval)))
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
___XXX_X_XXX___Connect With a Mentor Commented:
If strString is the string that you want to convert to long use this:

Dim strString As String
Dim lngLong As Long

strString="53224356"
lngLong=Clng(Val(strString))






Or just:
lngLong=Val(strString)
0
 
g0rathCommented:
LONG in VB = -2,147,483,647 to 2,147,483,647
DOUBLE in VB = 4.94065645841247E-324 to 1.79769313486232E308 and stored as IEEE 64-bit 8 byte numbers

there isn't a "real" unsigned long int in VB, your more or less just typecasting to something larger that just so happens to hold those values. Just be warned if this is necessary for file I/O as it's 8 bytes not 4 in case that is an issue
0
 
___XXX_X_XXX___Commented:
Yes, g0rath is right, but Long type in VB is only "native" type in VB that is integer and big enough to hold 2^32 values (half negative and other positive) and it is close enough to unsigned long in C.
Mathematical operation with Long variable will result in Long variable (integer).
If you use Double value type, these 64 bits can't contain all 1.79*10^308 values and mathematical operations with it can contain non-exact results, but may contain values larger than 2^31 (the upper bound for Long variables).

If you don't want to make non-integer mathematical operations with Long variable, it will suits your needs in interval -2^31 to +2^31.
0
 
Mikal613Commented:
Shkoach
0
 
___XXX_X_XXX___Commented:
"Shkoach" ???
0
 
mnorma12Author Commented:
Sorry it's taken me so long to get back to you guys. I've been away from my computer since yesterday afternoon. I'll give a few of these a try and get back to you.

Thanks
0
 
mnorma12Author Commented:
The expression I am needing to duplicate is

ZoneNumber=strtoul(UTMZone, &ZoneLetter, 10)

What would this look like in Vb?
0
 
mnorma12Author Commented:
Thanks guys that wasn't as hard as I thought it might be. When I went through and read a summary of the strtoul routine I just got more confused. Anyways great work!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.