I know that a string varaible has a limit in size (I think it is 256 characters - please correct me if I am wrong) is there any way to use a string which is biggrer than that inside a variable ?
Printable View
I know that a string varaible has a limit in size (I think it is 256 characters - please correct me if I am wrong) is there any way to use a string which is biggrer than that inside a variable ?
I think the size limit of a string is 2gb...
How come nobody ever reads the Help-files before asking a question here?
Type in something like Dim Q as String, put your cursor on the "String" keyword and hit F1. The select "String Data Type". This is what the helpfiles will tel you:
Quote:
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 a class module.
The codes for String 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. The type-declaration character for String is the dollar sign ($).
How do you declare fixed-length strings?
To make it more clear try this code:Code:Dim FLString as String * 25
Enjoy!Code:Dim FLString As String * 25
FLString = "Hello"
' Watch out! The Len(FLString) is STILL 25!!
Debug.Print "[" & FLString & "]"
Debug.Print "[" & Trim(FLString) & "]"
FLString = "Hello this line is a very long one!!!"
' The Len(FL String) is now STILL 25!!
Debug.Print "[" & FLString & "]"
Debug.Print "[" & Trim(FLString) & "]"
Thanks, that cleared things up.
So Fixed Length string take up less resources huh?
No, a "Dynamic" string will be more resource friendly if you asked me. I think a Dynamic string is just a pointer to a memory location. If the size overgrows the previous size then some extra memory will be allocated. A fixed length string always takes up the number of chars that fit + another byte or 2 maybe even 4) for pointer data etc...