Google Answers Logo
View Question
 
Q: VB Run-time error 6 Overflow ( No Answer,   4 Comments )
Question  
Subject: VB Run-time error 6 Overflow
Category: Computers > Programming
Asked by: xymox-ga
List Price: $10.00
Posted: 19 Jun 2002 21:01 PDT
Expires: 26 Jun 2002 21:01 PDT
Question ID: 29552
I'm parsing large amounts of text in VB and get this error: "VB
Run-time error 6 Overflow" I'm using the Len function to count the
charter length and that is where the error is raised. Example: x =
Len(Text)

My question is how can I prevent this overflow error? Is there another
way to get string length say via an API call? Is Len running out of
memory and is there a way to increase it?

Request for Question Clarification by xemion-ga on 19 Jun 2002 21:22 PDT
From the MSDN library:

"Long data type
A 4-byte integer ranging in value from -2,147,483,648 to
2,147,483,647. The ampersand (&) type-declaration character represents
a Long in Visual Basic."

The Len function uses the Long data type.  Just to clarify, your text
is not over 2,147,483,647 characters, correct?  If it's longer than
that, then that's probably your problem.  Thanks!

xemion-ga

Clarification of Question by xymox-ga on 19 Jun 2002 22:41 PDT
My text is nowhere near 2,147,483,647 characters so I'm not sure why I
get the overflow error. Current string size is only 500,000 +. Does
this help?

Request for Question Clarification by 8ball-ga on 20 Jun 2002 02:07 PDT
Can you post the source code for the function/method call in which
this error occurs?

Sometimes it is easier to see what is going on if you see the code.

Clarification of Question by xymox-ga on 20 Jun 2002 06:47 PDT
This question has been answered by blcman-ga. Thank you and everyone
else for your comments. His answer to declare x as Long works
perfectly.
Answer  
There is no answer at this time.

Comments  
Subject: Re: VB Run-time error 6 Overflow
From: blcman-ga on 19 Jun 2002 22:56 PDT
 
You must declare "x" as a long data type.
For example:

Dim x as integer
x = len(longstring) 'Longstring is a string over 32,768 characters in
length


Would cause an overflow error

Dim x as long
x = len(longstring) 'Longstring is a string over 32,768 characters in
length

Would work


The integer data type only allows values from -32,768 to 32,768. More
or less than that and you get an overflow error.
Subject: Re: VB Run-time error 6 Overflow
From: gking-ga on 20 Jun 2002 01:30 PDT
 
how are getting the string for which u want find the length, is it
coming from a database or from a file...
Subject: Re: VB Run-time error 6 Overflow
From: mangeshp16-ga on 20 Jun 2002 13:28 PDT
 
How about breaking the entire string in chunks of equal size and
getting length of each chunk. add all these lengths to get length of
entire string.
eg.
vStr="long string"
if len(vStr) > 32000 then
  break the string in chunks
end if
for i=0 to ubound(chunk)
 vLen=vLen & len(chunk(i))
next
Subject: Re: VB Run-time error 6 Overflow
From: bineshjm-ga on 21 Jun 2002 04:54 PDT
 
This problem not VB
Your window's files some corrupted.
You should reinstall and run your program.
I excpet surlty work your program

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy