|
-
Sep 17th, 2002, 07:19 AM
#1
Thread Starter
Hyperactive Member
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
-
Sep 17th, 2002, 07:21 AM
#2
PowerPoster
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
-
Sep 17th, 2002, 07:23 AM
#3
Let me in ..
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.
-
Sep 17th, 2002, 07:25 AM
#4
Thread Starter
Hyperactive Member
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
-
Sep 17th, 2002, 08:29 AM
#5
I wonder how many charact
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:
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:
stringbuffer = stringbuffer & ";" & strNewEnvVarShort
stringbuffer is neither declared nor initialized before the above command. Therefore, I cannot tell how it was declared or initialized.
-
Sep 17th, 2002, 08:49 AM
#6
Frenzied Member
It could also be that passing the string back to the Shell command that limits it to 255 characters.
-
Sep 17th, 2002, 09:11 AM
#7
could you post the code for readCurrentRegEnv? It might be the source of the problem.
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
|