×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

say...

you have a set of data like this

id name
---------------
123 toronto
124 scarbo
125 north york
---------------

when add to the list, do

listbox.additem "toronto"
listbox.itemdata(listbox.newindex) = 123

listbox.additem "scarbo"
listbox.itemdata(listbox.newindex) = 124

listbox.additem "north york"
listbox.itemdata(listbox.newindex) = 125
,,,

when retrieve do this

id = listbox.itemdata(listbox.listindex) '// say if you select toronto for the moment

id would be 123, then using 123 to retrieve 'toronto' from the
original list

was that what you want ?
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / VB中如何把listbox中的记录绑定另外一个数字?
    原来记录中有唯一编号,在listbox中显示它的描述,有什么方法可以在click这个listbox的时候得到那个编号?

    谢谢
    • the original unique gotta be numeric
      then listbox.itemdata(i)=id to save, id=listbox.itemdata(i) to retrieve
      • 你意思是listbox1.additem "abce",以后,再把abce的唯一数字标示,如果是1234,listbox1.itemdata(****)=1234,(其中****是它的listindex)?谢谢
        • say...
          you have a set of data like this

          id name
          ---------------
          123 toronto
          124 scarbo
          125 north york
          ---------------

          when add to the list, do

          listbox.additem "toronto"
          listbox.itemdata(listbox.newindex) = 123

          listbox.additem "scarbo"
          listbox.itemdata(listbox.newindex) = 124

          listbox.additem "north york"
          listbox.itemdata(listbox.newindex) = 125
          ,,,

          when retrieve do this

          id = listbox.itemdata(listbox.listindex) '// say if you select toronto for the moment

          id would be 123, then using 123 to retrieve 'toronto' from the
          original list

          was that what you want ?
          • yes, Thank you very much