I'm facing issues working with VBA and noting that it has a string limitation to 255 characters. I'm actually trying to send a JSON through POST and pausing the execution I note that the string has always just 255 characters.
Is there a way to resize the string or something?
I wasted around 6 hours into this problem to finally check that it was just a DEBUGGER LIMITATION . The VBA debugger just shows 255 characters of the string, but it doesn't mean that it contains just what he's showing.
I noticed about this when things were getting crazy and it went to the surface when I used a MsgBox
with a Len
to check the string size and content.
Hope it helps, because I read lots of people asking for this but nobody told about it.
If you want to print something on the console (immediate window) you may simply Print it to a notepad, the result would be theoretically the same and above the 255 lines (not characters). Here is how to print the numbers from 1 to 10.000 in a notepad:
Option Explicit
Public Sub PrintToNotepad()
Dim strShell As String
Dim strFileName As String
Dim fs As Object
Dim objText As Object
strFileName = ThisWorkbook.Path & "\test" & Replace(Now, ":", "")
Set fs = CreateObject("Scripting.FileSystemObject")
Set objText = fs.CreateTextFile(strFileName, True)
objText.writeline (GenerateBigString)
strShell = "C:\WINDOWS\notepad.exe" & " "
strShell = strShell & strFileName
Call Shell(strShell)
End Sub
Public Function GenerateBigString() As String
Dim i As Long
Dim result As String
For i = 1 To 10000
result = result & i & vbCrLf
Next i
GenerateBigString = result
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With