Results 1 to 7 of 7

Thread: string size

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2001
    Posts
    302

    string size

    How many characters can a string hold?

    I need to read a very long string and pass it to an external exe. I am currently using a string to store the data, but when it is over 255, the string gets messed up...

    Any ideas?


    thanks

  2. #2
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    From VB Help:

    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.

    Roy

  3. #3
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    How long is your long data ?

    String can hold ...

    (variable-length) 10 bytes + string length
    0 to approximately 2 billion.

    I cannot imagine your need is bigger than this.


  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2001
    Posts
    302
    Can you see a problem with my code?

    Dim stringbufferOld As String

    Call readCurrentRegEnv

    strNewEnvVarShort = Command$()

    If strNewEnvVarShort = "" Then
    MsgBox "Path to append is null. Please enter a valid path", vbCritical, "ERROR!"
    Unload Me
    Exit Sub
    End If

    ' remove "\" from the end of the new string
    Do While Right(strNewEnvVarShort, 1) = "\"
    strNewEnvVarShort = Left(strNewEnvVarShort, Len(strNewEnvVarShort) - 1)
    Loop

    stringbufferOld = stringbuffer
    stringbuffer = stringbuffer & ";" & strNewEnvVarShort
    myArray = Split(stringbuffer, ";")
    numbPaths = UBound(myArray) + 1
    For i = 0 To numbPaths - 1
    If Not myArray(i) = "" Then
    If Not i = numbPaths - 1 Then
    strNewEnvVar = strNewEnvVar & myArray(i) & ";"
    Else
    strNewEnvVar = strNewEnvVar & myArray(i)
    End If
    End If
    Next i

    'check if the new path statement already exists in current path
    If InStr(stringbufferOld, strNewEnvVarShort) > 0 Then
    'MsgBox "exists"
    Else
    'MsgBox "doesn't exist"
    strPath = """" & strNewEnvVar & """" & " -m" 'system variables
    Shell (App.Path & "\setx.exe " & "PATH " & strPath)
    MsgBox (App.Path & "\setx.exe " & "PATH " & strPath)
    End If
    'default path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
    Unload Me
    Exit Sub

    End Sub



    Call readCurrentRegEnv === returns existing environment path

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I haven't thoroughly checked the logical processing of your code, but I may first suspect the Command() function may only return 255 characters...

    try checking the length of strNewEnvVarShort after this :
    VB Code:
    1. strNewEnvVarShort = Command$()

    to see if it does not mess it up....

    Also, I don't see enough information in the cost you posted about this:
    VB Code:
    1. stringbuffer = stringbuffer & ";" & strNewEnvVarShort

    stringbuffer is neither declared nor initialized before the above command. Therefore, I cannot tell how it was declared or initialized.

  6. #6
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    It could also be that passing the string back to the Shell command that limits it to 255 characters.

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    could you post the code for readCurrentRegEnv? It might be the source of the problem.
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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