Conversion from string value to long integer. 
Author Message
 Conversion from string value to long integer.

Hello!
In VBDos there is a function called CVL that takes a 4 character
string and converts it to a long integer.
E.g. CVL("aaaa")=1633771873
I am using VB 5.0 in which this function is not supported.
How can this be achieved in VB 5.0?

Thanks alot in advance for any answers!
Andreas



Fri, 10 Nov 2000 03:00:00 GMT  
 Conversion from string value to long integer.

On Mon, 25 May 1998 15:12:32 +0200, Andreas Werner Paulsen

Quote:

>Hello!
>In VBDos there is a function called CVL that takes a 4 character
>string and converts it to a long integer.
>E.g. CVL("aaaa")=1633771873
>I am using VB 5.0 in which this function is not supported.
>How can this be achieved in VB 5.0?

Hello,

the function CLng converts from any valid expression to long. If your
string is valid, i.e. it contains only decimal digits and eventually a
+ or - sign at first, it is converted.
A long has the range from -2,147,483,648 to 2,147,483,647 so your
number is within that range.

By
Uwe Hercksen

For EMail response, please use:
User: hercksen
sub-domain: mew
domain: uni-erlangen
country: de
--------------------------------------------------
Elektronikwerkstatt Uni. Erlangen
Cauerstr. 5
D91058 Erlangen



Fri, 10 Nov 2000 03:00:00 GMT  
 Conversion from string value to long integer.

Andreas -
    In spite of what some other responses have said, CVL is nothing like
CLng().  CVL and its cousins are "type casts".  They just provide a means of
treating the same block of memory in two different ways.

    Since VB strings are Unicode internally, the CVx and MKx functions would
not necessarily work the same way they used to, so they were dropped.  You
can emulate CVL by using RtlMoveMemory to copy the bytes from a string to a
long, but it's best if you never let the bytes become a string in the first
place... use a byte array instead.

    My company's Stamina library provides CVx/MKX replacements, but with the
caveat that due to the Unicode issue, they may go quirky when used between a
system with a Western language and one with a DBCS language like Chinese.

--
     Jim Mack
     MicroDexterity, Inc
     PO Box 5372
     Plymouth, MI  48170-5372

     http://www.microdexterity.com



     Fax:  +1 734-453-8942

Quote:

> Hello!
> In VBDos there is a function called CVL that takes a 4 character
> string and converts it to a long integer.
> E.g. CVL("aaaa")=1633771873
> I am using VB 5.0 in which this function is not supported.
> How can this be achieved in VB 5.0?



Fri, 10 Nov 2000 03:00:00 GMT  
 Conversion from string value to long integer.

On Mon, 25 May 1998 15:12:32 +0200, Andreas Werner Paulsen

Quote:

>Hello!
>In VBDos there is a function called CVL that takes a 4 character
>string and converts it to a long integer.
>E.g. CVL("aaaa")=1633771873
>I am using VB 5.0 in which this function is not supported.
>How can this be achieved in VB 5.0?

>Thanks alot in advance for any answers!
>Andreas

If I remember correctly, the CVL function took a four byte variable
and treated it like a Long Integer (basically just taking the four
bytes and copying it directly to the memory used by a Long Integer).
It didn't "convert" the string variable as much as it "cast" it into a
Long integer.

Try some of the various CopyMem functions or possibly even the LSET
function.  

HTH,

Barry
eggers1 AT tsil DOT net



Sun, 12 Nov 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. String to Integer conversion using CInt() ?

2. Binary conversion Integer -> String

3. Help: converting long integer colour values to RGB

4. ChkList Boxes and long integer values

5. String to Integer conversion problem

6. Converting integers and long integers to byte arrays

7. Long = Integer * Integer Overflow error

8. long - string conversion

9. Enum String Value (deriving from a Type Name and an Integer)

10. Converting values from strings to integers

11. Numerical value to String conversion

12. Debug: How to copy value of long string?

 

 
Powered by phpBB® Forum Software