ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ListBox value limit (https://www.excelbanter.com/excel-programming/339607-listbox-value-limit.html)

John[_88_]

ListBox value limit
 
Hi there,

I've come across a weird issue with listbox value sizes. The code below
adds an item to the list, that increments one character at a time. However,
it falls over with a "2147352571 - Type mismatch" error. The length of the
string at that stage is 2048. Can anyone tell why this is happening?

Thanks

John


Private Sub UserForm_Initialize()
Dim sCharacters As String
For X = 1 To 3000
sCharacters = sCharacters & "a"
Me.ListBox1.AddItem sCharacters
Debug.Print CStr(Len(sCharacters))
Next X
End Sub



ACFalcon

ListBox value limit
 
I believe that the max length that a string can be is 2048.

"John" wrote:

Hi there,

I've come across a weird issue with listbox value sizes. The code below
adds an item to the list, that increments one character at a time. However,
it falls over with a "2147352571 - Type mismatch" error. The length of the
string at that stage is 2048. Can anyone tell why this is happening?

Thanks

John


Private Sub UserForm_Initialize()
Dim sCharacters As String
For X = 1 To 3000
sCharacters = sCharacters & "a"
Me.ListBox1.AddItem sCharacters
Debug.Print CStr(Len(sCharacters))
Next X
End Sub




John[_88_]

ListBox value limit
 
Hi AC,

Thanks for this. I'm curious though, because in another procedure I'm able
to pass a string around so to speak, which is over 9000 characters in
length?

John

"ACFalcon" wrote in message
...
I believe that the max length that a string can be is 2048.

"John" wrote:

Hi there,

I've come across a weird issue with listbox value sizes. The code below
adds an item to the list, that increments one character at a time.
However,
it falls over with a "2147352571 - Type mismatch" error. The length of
the
string at that stage is 2048. Can anyone tell why this is happening?

Thanks

John


Private Sub UserForm_Initialize()
Dim sCharacters As String
For X = 1 To 3000
sCharacters = sCharacters & "a"
Me.ListBox1.AddItem sCharacters
Debug.Print CStr(Len(sCharacters))
Next X
End Sub







All times are GMT +1. The time now is 02:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com