What is the difference between List() and List used in the code below? They both appear to do the same thing?
Private Sub UserForm_Initialize()
Dim myArray As Variant
myArray = Split("A|B|C", "|")
ListBox1.List = myArray
'ListBox1.List() = myArray
End Sub
The List Property Help states that the row and column part (the parts that go inside the parens) "is required."
"row Required. An integer with a range from 0 to one less than the number of entries in the list.
column Required. An integer with a range from 0 to one less than the number of columns."
From the example code above, those parts don't appear to be required. What does "required" mean in this case?
The List property Help states:
"Use List to copy an entire two-dimensional array of values to a control. Use AddItem to load a one-dimensional array or to load an individual element."
In the example above List seems to work perfectly well for loading a one-dimensional array (provided I understand what that is). Why would the Help file not propose using List for a one-dimensional array?
How should AddItem be used to load a one-dimensional array?
Private Sub UserForm_Initialize()
Dim i As Long
Dim myArray As Variant
myArray = Split("Professor Jones|Professor Miller|Professor Klumpp", "|")
ListBox1.AddItem myArray
End Sub
Causes a runtime error.
The following works, but seems a stupid way to do it since List appears to work perfectly well.
Private Sub UserForm_Initialize()
Dim i As Long
Dim myArray As Variant
myArray = Split("Professor Jones|Professor Miller|Professor Klumpp", "|")
'Build directly from an Array
For i = 0 To UBound(myArray)
Me.ListBox1.AddItem myArray(i)
Next i
End Sub

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Reur final question - There's more ways than one to kill a cat; Some are
better than others.

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
What is the difference between List() and List used in the code below? They
both appear to do the same thing?
Private Sub UserForm_Initialize()
Dim myArray As Variant
myArray = Split("A|B|C", "|")
ListBox1.List = myArray
'ListBox1.List() = myArray
End Sub
The List Property Help states that the row and column part (the parts that
go inside the parens) "is required."
"rowRequired. An integer with a range from 0 to one less than the number of
entries in the list.
columnRequired. An integer with a range from 0 to one less than the number
of columns."
From the example code above, those parts don't appear to be required. What
does "required" mean in this case?
The List property Help states:
"Use List to copy an entire two-dimensional array of values to a control.
Use AddItem to load a one-dimensional array or to load an individual
element."
In the example above List seems to work perfectly well for loading a
one-dimensional array (provided I understand what that is). Why would the
Help file not propose using List for a one-dimensional array?
How should AddItem be used to load a one-dimensional array?
Private Sub UserForm_Initialize()
Dim i As Long
Dim myArray As Variant
myArray = Split("Professor Jones|Professor Miller|Professor Klumpp", "|")
ListBox1.AddItem myArray
End Sub
Causes a runtime error.
The following works, but seems a stupid way to do it since List appears to
work perfectly well.
Private Sub UserForm_Initialize()
Dim i As Long
Dim myArray As Variant
myArray = Split("Professor Jones|Professor Miller|Professor Klumpp", "|")
'Build directly from an Array
For i = 0 To UBound(myArray)
Me.ListBox1.AddItem myArray(i)
Next i
End Sub

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Greg Maxey - 19 Jan 2007 12:57 GMT
Doug,
Are you confirming that AddItem can't be used without sequencing
through the array members one at a time to load a one dimensional array
into a listbox?
If so and echoing Shauna remarks, the Help file just isn't really very
helpful at all ;-). It seems to provide plenty of suggestions that
don't work perhaps with the intent the help seeker will then stumble on
what does.
> Reur final question - There's more ways than one to kill a cat; Some are
> better than others.
[quoted text clipped - 58 lines]
> http://gregmaxey.mvps.org/word_tips.htm
> For some helpful tips using Word.
Doug Robbins - Word MVP - 19 Jan 2007 15:16 GMT
Sorry, the reference to a question was not correct. The statement was made
in connection with your observation "The following works, but seems a stupid
way to do it "

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Doug,
>
[quoted text clipped - 76 lines]
>> http://gregmaxey.mvps.org/word_tips.htm
>> For some helpful tips using Word.
Hi Greg,
The help is not all that helpful or correct.
1. There is no difference between List and List() when you are assigning the
entire listbox to/from a 2-d array.
2. When you want to use the List property to read or write a single element
of the listbox, you need both the row and column numbers - even for a
1-column listbox.
3. You can assign a 1-d array to the List property of a listbox and get a
1-column listbox as a result. This is not directly documented, but it works.
4. If you assign the List property to an array, it will always be a 2-d
array, even if there is only one column in the listbox. In the case of a
1-col list, the items will be sArray(0,0) to sArray(n,0)
5. You can't use AddItem to assign an array to a new row of the listbox. If
you use AddItem on a multicolumn listbox, AddItem creates a new row, and
inserts the string into the first column, leaving the other columns blank
for that row. You then have to assign values to List(row, col) to fill in
the rest of the columns.
By the way, could you fix your newsreader so it doesn't send
Quoted-Printable text? An effect of QP is that ">" indents don't appear when
replying, which makes doing inline replies rather more difficult...

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
What is the difference between List() and List used in the code below? They
both appear to do the same thing?
Private Sub UserForm_Initialize()
Dim myArray As Variant
myArray = Split("A|B|C", "|")
ListBox1.List = myArray
'ListBox1.List() = myArray
End Sub
The List Property Help states that the row and column part (the parts that
go inside the parens) "is required."
"row Required. An integer with a range from 0 to one less than the
number of entries in the list.
column Required. An integer with a range from 0 to one less than the
number of columns."
From the example code above, those parts don't appear to be required. What
does "required" mean in this case?
The List property Help states:
"Use List to copy an entire two-dimensional array of values to a control.
Use AddItem to load a one-dimensional array or to load an individual
element."
In the example above List seems to work perfectly well for loading a
one-dimensional array (provided I understand what that is). Why would the
Help file not propose using List for a one-dimensional array?
How should AddItem be used to load a one-dimensional array?
Private Sub UserForm_Initialize()
Dim i As Long
Dim myArray As Variant
myArray = Split("Professor Jones|Professor Miller|Professor Klumpp", "|")
ListBox1.AddItem myArray
End Sub
Causes a runtime error.
The following works, but seems a stupid way to do it since List appears to
work perfectly well.
Private Sub UserForm_Initialize()
Dim i As Long
Dim myArray As Variant
myArray = Split("Professor Jones|Professor Miller|Professor Klumpp", "|")
'Build directly from an Array
For i = 0 To UBound(myArray)
Me.ListBox1.AddItem myArray(i)
Next i
End Sub

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Greg Maxey - 24 Jan 2007 00:52 GMT
Jonathan,
Thanks for the notes.
I think I have corrected the issue you mentioned with Quoted Printable text.
Can you confirm?

Signature
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
> Hi Greg,
>
[quoted text clipped - 85 lines]
> Next i
> End Sub
Jonathan West - 24 Jan 2007 01:03 GMT
C
> Jonathan,
>
> Thanks for the notes.
>
> I think I have corrected the issue you mentioned with Quoted Printable
> text. Can you confirm?
Confirmed :-)

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org