A combobox can be used to give a list of acceptable choices in a dropdown box, often when validating data input.
Put a combobox on your form:
2. Choose the Items property and click on (Collection)
3. Enter each valid option on a different line and click OK
4. Dropdown box shows on the form, when you run the code, so you can choose only a valid option.
Note: This is only an option if you are using textfiles to store data
Put a combobox on your form:
2. Put this code in the form_load procedure. It will loop through a textfile created previously, and pull out all the usernames from each record in the file (first 10 characters).
<--- This is the current contents of pupildetails.txt
3. When you run the code, the combobox is populated as follows:
You refer to the contents of a combobox in the same way as a text box i.e. by the use of the .text property
txtUsernameSearch.text for textboxes, cmbUsernameSearch.text for comboboxes (look at the code)
In this example, the Username combobox has already been populated (see above).
A username is chosen and the Search button pressed.
The data from the file for DaviesK3 is then displayed in the textboxes below, using cmbUsernameSearch.text to search to textfile for a match.
Here is the code: