473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to show the table in the list box

24
Hello maybe you know how to show the table in the list box? for example I want to show this results in the list box:


vegetables fruits
Tomato apple
cucumber apricot
Apr 27 '07 #1
6 11559
SammyB
807 Expert 512MB
Hello maybe you know how to show the table in the list box? for example I want to show this results in the list box:


vegetables fruits
Tomato apple
cucumber apricot
What VB are you using? VBA(if so, which application), VB6, or VB.Net?

If you are using VB.Net, you might want to consider using a ListView control instead:
  1. Add a ListView control
  2. In the Design Mode, add two columns to the Columns property: Vegetables, Fruits
  3. In the form load event, you can load the rows:
Expand|Select|Wrap|Line Numbers
  1. ListView1.View = View.Details
  2. ListView1.Items.Add(New ListViewItem(New String() {"Tomato", "Apple"}))
  3. ListView1.Items.Add(New ListViewItem(New String() {"Cucumber", "Apricot"}))
HTH --Sam
Apr 27 '07 #2
Eglute
24
I use VB 6.0
Apr 27 '07 #3
SammyB
807 Expert 512MB
I use VB 6.0
Bummer! If I remember correctly, you'll have to do it yourself. In other words, you'll have to insert enough spaces so that it looks like you have columns. I also remember using multiple listboxes placed together so that they looked like a single multiple column listboxes. But coordinating selection/scrolling was a pain.

Maybe Killer will have some good suggestions when he arrives later this evening. I also be back to a VB6 machine in a couple of hours and I'll see if I still have any pseudo-column code.

Another thought: if you have Microsoft Office installed on your computer, then you should be able to add Microsoft Forms 2.0 ListBox to your form. Right-click on the toolbox and browse to \Windows\System32\FM20.dll, then add the ListBox to your project. With it you use the ColumnCount property. Here's some sample code, http://msdn2.microsoft.com/en-us/lib...ffice.11).aspx. I'll see if it works for VB6 in a couple of hours. HTH --Sam
Apr 27 '07 #4
SammyB
807 Expert 512MB
Forms 2.0 ListBox works!:
Expand|Select|Wrap|Line Numbers
  1.     Dim lstArray(3, 2) ' three rows, two columns
  2.     ListBox1.ColumnCount = 2
  3.     lstArray(0, 0) = "Vegetables"
  4.     lstArray(1, 0) = "Tomato"
  5.     lstArray(2, 0) = "Cucumber"
  6.     lstArray(0, 1) = "Fruits"
  7.     lstArray(1, 1) = "Apple"
  8.     lstArray(2, 1) = "Apricot"
  9.     ListBox1.List() = lstArray
But, it has an annoying "feature:" the ColumnHeads only works if the control is getting the data from a RowSource & even then it gets the data before the RowSource ie, I think it will only work for Excel. But, the workaround is to just use Label controls for the headers. HTH --Sam
Apr 27 '07 #5
Eglute
24
I undestood this way, but it was only example. Now I want to show two or more records of my access database in one list box. I wrote a code such as:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command4_Click()
  2. List1.Clear
  3. Set db = OpenDatabase("the path of my database")
  4. Set rec = db.OpenRecordset("SELECT * From asmenu_info WHERE asmenu_info.Vardas in ('Eglë','Regina');")
  5. While Not rec.EOF
  6.   List1.AddItem rec!ID
  7.   rec.MoveNext
  8. Wend
  9. rec.Close
  10. db.Close
  11. End Sub
With this code I can add only one record to my list. I want to show more than one record in the list box.
Apr 28 '07 #6
Killer42
8,435 Expert 8TB
As far as I can see, the only reason this would be limited to a single record is if your WHERE clause does so. The While loop should add the entire recodset to the listbox.
Apr 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: WindAndWaves | last post by:
Hi Gurus I was wondering if you can send me in the right direction: I have a table with about 300 rows. I want to make all of them invisible and when a user enters a code in a form then make...
7
by: Anne M | last post by:
I have a report based on query..which is a team list with names and their role on team ie coach, assistant and player. Report is almost what I want and my knowledge is limited so I need some...
2
by: jeet_sen | last post by:
Hi, I have created a table colelcting data from an XML source. After I built the whole table I ahve given user options to filter out columns from the table. For this I have collected all the...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
1
by: basavaraj koti | last post by:
I need to show image using xslt Below provided in my xml and xslt. <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="../xyz.xsl"?> <Grade class="03"...
1
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
0
by: bimeldip | last post by:
Hi, I have managed to create codes to display data from the database in a html page.I have gone on to create a page to allow users to manipulate the table via a html page. For instance users will be...
2
by: banderson | last post by:
Hello, I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg...
39
by: alex | last post by:
I've converted a latin1 database I have to utf8. The process has been: # mysqldump -u root -p --default-character-set=latin1 -c --insert-ignore --skip-set-charset mydb mydb.sql # iconv -f...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.