Results 1 to 7 of 7

Thread: String size

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Canada
    Posts
    264
    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 ?
    In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.

    - Douglas Adams
    The Hitchhiker's Guide to the Galaxy

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    I think the size limit of a string is 2gb...
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Guest
    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:

    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 ($).

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    How do you declare fixed-length strings?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    Guest
    Code:
    Dim FLString as String * 25
    To make it more clear try this code:

    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) & "]"
    Enjoy!

  6. #6
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Thanks, that cleared things up.

    So Fixed Length string take up less resources huh?
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  7. #7
    Guest
    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width