473,394 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Convert a long string to integer

Hi,

I'm reading in a string of about 420 characters, the string is in binary. How do I either:
- convert a string of this length into an integer variable without getting a runtime error 6 (overflow error) which so far I have got from using CInt and Val commands.
- or read the file into an integer variable so that I can perform operations on it.

I've been searching for a while for this and can't find it anywhere, any help would be much appreciated. =)
Dec 6 '07 #1
7 4516
debasisdas
8,127 Expert 4TB
Since the string is in binary format you need to convert that to decimal first. still i doubt you can store the output decimal into an integer variable. Try using Long variable for the purpose.
Dec 6 '07 #2
The binary is simply 1's and 0's in a text file.

I've tried declaring the integer as long and still recieve an overflow error. I'll have to try something else I suppose.
Dec 6 '07 #3
QVeen72
1,445 Expert 1GB
Hi,

For 420 Chars, you will definately Receive an "OverFlow Error", You need to declare a String Variable and Read it.
So what kind of Operations are you trying to perform on that data...?

Regards
Veena
Dec 6 '07 #4
Yes so far I've read it into a string, its just slightly too long for an integer lol.

I need to split it up into groups of 7 bits and convert to decimal then convert to ASCII etc etc.

The problem is I can't perform maths on a string.

The only way I can think of so far is to split up the file into its 7 bits as a string, then convert that to an integer. I gave it a quick try and I still get an overflow error.
Dec 6 '07 #5
QVeen72
1,445 Expert 1GB
Hi,

Though 7 Chars is Still a Higher value for Integer(32k Max)
To be safer, You need to split to 4 Chars and try..

Regards
Veena
Dec 6 '07 #6
Oh right, I'll give that a go.

What about a long type?
Dec 6 '07 #7
QVeen72
1,445 Expert 1GB
Hi,

Long Datatype in VB6 has this Range:
-2,147,483,648 to 2,147,483,647

You can try, But You have to Split the Data to a Lesser number of Groups..
9 Chars in one Variable..

Regards
Veena
Dec 6 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sam Smith | last post by:
Hi, is there a function or a "well-known" algorithm which converts a number of random length represented as an array of bytes to its binary format? For example: a 16 byte long array:...
2
by: Mel WEaver | last post by:
Hello, I have the following delphi structure for a binary file. I'm looking for idea how to read this file. Mel type TMenuDataStruct = packed record exename : string;
3
by: Mike Miller | last post by:
What is the best way to convert a managed unsigned int64 to an unsigned long? Basically I need to do the following: System::UInt64 managedInt = 10; unsigned long unmanagedInt; unmanagedInt =...
17
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge...
15
by: Tanzim Saqib | last post by:
I've been trying to learn VB.NET. I know VB6. I can not convert the following VB6 code segment to VB.NET In VB 6: ' In a module starts here: Public Declare Function SetTimer Lib "user32"...
14
by: Michael Barrido | last post by:
I have this for example: Dim iSeconds as int32 = 3600 '3600 seconds is one hour How do i convert it to "01:00:00" ? Please help. Thanks in advance!
43
by: Steven T. Hatton | last post by:
http://public.research.att.com/~bs/bs_faq2.html#int-to-string Is there no C library function that will take an int and convert it to its ascii representation? The example Bjarne shows in his faq...
14
by: Drew | last post by:
Hi All: I know I am missing something easy but I can't find the problem! I have a program which reads an integer as input. The output of the program should be the sum of all the digits in the...
7
by: shellon | last post by:
Hi all: I want to convert the float number to sortable integer, like the function float2rawInt() in java, but I don't know the internal expression of float, appreciate your help!
8
by: te509 | last post by:
Hi guys, does anybody know how to convert a long sequence of bits to a bit-string? I want to avoid this: '949456129574336313917039111707606368434510426593532217946399871489' I would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.