I have a combobox (combobox1) with a list of names for example: CHARLY SUSAN BOB.
What I’m trying to achieve is to read the contents of a corresponding file in another combobox (combobox2) so
- CHARLY would open CHARLY.txt and populate combobox2 with that files
contents - SUSAN would open SUSAN.txt and populate combobox2 with that
files contents - BOB would open BOB.txt and populate combobox2 with
that files contents
The list of names its self is read from a text file this is because I would in future like to add more names.
These are read into (Combobox1) by the following code:
'Compiles list for plotter/ printer items...
ComboBox1.Items.AddRange(System.IO.File.ReadAllLines("C:\PEOPLE\NAMES.txt"))
I’m thinking to keep the concept open to an ever expanding list to set a variable/ string to the target name then add a prefix to it example being: BOBfile.txt with a suffix also added which would point to the target files directory thus then being C:\PEOPLE\BOBSfile.txt
This set in a variable would then open the concerning folder as follows:
ComboBox2.Items.AddRange(System.IO.File.ReadAllLines( BOBSVARIABLE ))
Dose anybody know how to achieve this?
Here is a simple example:
Do consider a database instead. Also, your current system wouldn’t handle duplicate names very well.