When you use Excel to write a VBA program, you use a ListBox, and then you examine all of its properties. In fact, this control function is very bad, too old, the most important thing is not support mouse wheel, very bad operation, but considering compatibility, or use it.
In fact, reading, writing data with Listbox.list is enough, and BoundColumn and TextColumn is mainly used to read data, what kind of bird? I'm not sure, but I can use it like this. These two parameters are equivalent to the index (j) of the column set, and the corresponding data list (I,J) can be read by simply selecting the row (i). Where BoundColumn is associated with value; TextColumn is associated with text.
Private SubCommandButton1_Click () Listbox1.listindex=0 'If the first row is selected , the value is not read,Listbox1.BoundColumn =2 'the property counts from 1, which now corresponds to a column index of 1; The default value is 1Listbox1.textcolumn =3 'the property counts from 1, which now corresponds to a column index of 2; The default value is-1, which cannot be read if no value is assignedDebug.Print"value ="& Listbox1.Value'Output value = 0,1Debug.Print"Text ="& Listbox1.text'output Text = 0,2End SubPrivate Subuserform_initialize ()DimI as Integer DimJ as IntegerListbox1.columncount=5 'Set 5 Columnsi =0 whileI <TenListBox1.AddItem J=0 whileJ <Listbox1.columncount Listbox1.List (i, J)=CStr(i) &","&CStr(j) J= j +1Wend I= i +1WendEnd Sub
Keywords: VBA ListBox BoundColumn TextColumn Value Text Description parameter use method Excel
BoundColumn and TextColumn usages of the VBA control ListBox, value and text usage