|
-
Aug 6th, 2001, 03:11 PM
#1
Thread Starter
PowerPoster
string limit
how much text can I put into a string variable
-
Aug 6th, 2001, 03:12 PM
#2
PowerPoster
something like 2 billion chars, or when you run out of memory, whichever happens sooner.
-
Aug 6th, 2001, 03:30 PM
#3
Registered User
4 GB for a variable-length string
64k for fixed-length string
-
Aug 6th, 2001, 03:42 PM
#4
Thread Starter
PowerPoster
That should just about do it!
Thanks guys.
-
Aug 6th, 2001, 03:54 PM
#5
Frenzied Member
I think you cant reach the 4 GB only if you have close to 4 gb ram.
-
Aug 6th, 2001, 03:59 PM
#6
Member
Some functions are freaky. Mid only does strings that have 65,535 (unsigned int) chars at most.
-
Aug 6th, 2001, 04:08 PM
#7
Frenzied Member
Not true try this
VB Code:
ss = String(70000, "l") & "this is more than 69000 spaces Hello"
ss = Mid(ss, 69000)
MsgBox ss
It works
-
Aug 6th, 2001, 08:04 PM
#8
Hyperactive Member
Vb / Reference / Additional Info / Data Type Summary
String
(variable-length) 10 bytes + string length 0 to approximately 2 billion
-
Aug 6th, 2001, 08:15 PM
#9
Originally posted by Nucleus
4 GB for a variable-length string
64k for fixed-length string
It's actually 2 GB for variable-length strings. Every process in Windows gets a virtual memory space of 4 GB but 2 of them is reserved for Windows itself. So that leaves you with 2 GB of space.
But then again you can't have any other code besides the string in that case. But who cares the strings can be huge anyway.
-
Aug 6th, 2001, 08:24 PM
#10
2GB is also the file size limit on Win95 or 98, so maybe if you have a better file system, string lengths could be bigger...
I have absolutely no idea, but it seems logical.
I think the exact number of characters a string can have is:
2 ^ 31 = 2,147,483,648
-
Aug 7th, 2001, 06:06 AM
#11
Hyperactive Member
Th formulla is 10 + string Length 0 to 2 billion BUT number of bytes in string is 2 * string length (2 bytes Unicode per character). 2 Gig characters = 4 Gig bytes?
-
Aug 7th, 2001, 06:07 AM
#12
Member
Originally posted by shragel
Not true try this
VB Code:
ss = String(70000, "l") & "this is more than 69000 spaces Hello"
ss = Mid(ss, 69000)
MsgBox ss
It works
Sorry, I mean InStr.
-
Aug 7th, 2001, 08:05 AM
#13
Originally posted by John Yingling
Th formulla is 10 + string Length 0 to 2 billion BUT number of bytes in string is 2 * string length (2 bytes Unicode per character). 2 Gig characters = 4 Gig bytes?
That is 0 to 2 billion bytes not characters.
-
Aug 7th, 2001, 08:05 AM
#14
Member
So up to 1 billion chars.
-
Aug 7th, 2001, 09:50 AM
#15
Frenzied Member
In VB help under the String Data Type is says that the max length is 2^31 chars, unless you run out of memory first. Another way of remembering that would be to remember that strings can hold the maximum number of a Long variable plus 1.
You just proved that sig advertisements work.
-
Aug 7th, 2001, 10:07 AM
#16
Frenzied Member
originally posted by shragel
Not true try this
VB Code:
ss = String(70000, "l") & "this is more than 69000 spaces Hello"
ss = Mid(ss, 69000)
MsgBox ss
It works
Sorry, I mean InStr.
This also works
VB Code:
ss = String(70000, "l") & "this is more than 69000 spaces Hello"
ss = InStr(ss, "t")
MsgBox ss
-
Aug 7th, 2001, 10:14 AM
#17
From the MSDN CD:
'###########################
String Data Type
There are two kinds of strings: variable-length and fixed-length strings.
A variable-length string can contain up to approximately 2 billion (2^31) characters.
A fixed-length string can contain 1 to approximately 64K (2^16) characters.
Note APublic fixed-length string can't be used in aclass module.
The codes forString characters range from 0–255. The first 128 characters (0–127) of the character set correspond to the letters and symbols on a standard U.S. keyboard. These first 128 characters are the same as those defined by theASCII character set. The second 128 characters (128–255) represent special characters, such as letters in international alphabets, accents, currency symbols, and fractions. Thetype-declaration character for String is the dollar sign ($).
-
Aug 7th, 2001, 10:48 AM
#18
Member
Originally posted by shragel
VB Code:
ss = String(70000, "l") & "this is more than 69000 spaces Hello"
ss = InStr(ss, "t")
MsgBox ss
Arg, I know some string function fails because MS wrote it using unsigned int as an index pointer. I thought it was InStr or Mid, but know, who knows?
-
Aug 7th, 2001, 12:33 PM
#19
transcendental analytic
Originally posted by John Yingling
Th formulla is 10 + string Length 0 to 2 billion BUT number of bytes in string is 2 * string length (2 bytes Unicode per character). 2 Gig characters = 4 Gig bytes?
That is correct. A variable length string can take up to 4GB+10 bytes, a byte string could obtain 2^32 characters.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 7th, 2001, 12:52 PM
#20
Frenzied Member
Is there anyone who has a problem with the limit.
If not whats the difference of the exact limit??
-
Aug 7th, 2001, 08:08 PM
#21
-
Aug 7th, 2001, 08:16 PM
#22
transcendental analytic
Most of the time, you shold stay to unicode, since everything that is displayed as text is interpreted as unicode. Anyway, if you want to store large amount of characters 0 trough 255 you can use Strconv(stringname,vbfromUnicode) to return a byte array instead. And to convert back you can use Strconv(stringname,vbUnicode)
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|