BoundColumn and TextColumn usages of the VBA control ListBox, value and text usage

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.