|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
text file contents to combo box
hi
I have a text file like so: "num","name" where 'num' is a unique number upto 5 characters and the name is small, less than 15 characters On my form i have a combo box and text box im trying to link together as follows: have the combo box holding the values of 'num' and when someone selects one from the combo box the text box holds the 'name' that matches the num I was hoping someone could throw some light on this, just getting the 'num' parts into the combo box would be a great start All the best B.P |
|
#2
|
||||
|
||||
|
try this:
PHP Code:
This is untested ![]() please let me know if it works BTW. This will let you have up to 20 numbers and names. any more than that and you'll have to increase the no. 20's and the no. 19 by the same amount.... |
|
#3
|
|||
|
|||
|
Thanks for your post
I have a problem with this tho Private Sub cboCentreNumber_Change() txtCentreDescription.Text = sName(cboCentreNumber.Text) End Sub i get a subscript out of range error Any ideas Thanks again B.P |
|
#4
|
||||
|
||||
|
ooops
try this new code: PHP Code:
ps: you might want to lock text1 |
|
#5
|
|||
|
|||
|
Hi
umm i cant see what you changed there apart from '.value' to '.text' which was what i was trying to start with B.P |
|
#6
|
||||
|
||||
|
have you got anything set differently to defaults on your text and combo boxes?
and is your file in the format: 1, "hi" 2, "hello" 3, "123 testing" and there are no blank lines at the end? also, what system are you running it on? |
|
#7
|
||||
|
||||
|
btw. this works on my system fine (i tested it for you)
i'm running Win 2000 with VB6 |
|
#8
|
|||
|
|||
|
text files are all set up as you specified so that shoulndt be a problem
System is a windows2000 box Everything works ok, it inputs to the combo box fine, its just trying to update the text box that i get the subscript out of range error from the section: Private Sub cboSubjectRef_Change() text1.Text = sName(combo1.Text) End Sub The only thing not default on the combo box is that its sytle is set to dropdown list - but the list being inputted into the combo box is working fine so i dont see that a problem can i dim the sName and sNum too high? |
|
#9
|
||||
|
||||
|
what you set them to?
|
|
#10
|
|||
|
|||
|
Both set to 100, i thought i'de put it to that to be on the safe side
|
|
#11
|
||||
|
||||
|
they should be fine, as it is reading in ok....
i'm not sure of your problem! is the text box properties set to default? can you attach a screenshot of your error? |
|
#12
|
|||
|
|||
|
ok i have it working a differnet way now using two combo boxes : )
still not sure why it gave the error tho thanks for your help, was great All the best B.P |
|
#13
|
|||
|
|||
|
Hello..
Ive had to re-open this post.. as an addition to it is needed :/ I now need to be able to delete a line from this file.. and also be able to add on to it.. I have been able to add/delete records to files before on other programs ive made.. but i let VB do it and output to the file VB's way.. not in a humun-readable way like i need now For example, the ways i have used before would output to a file something like: ČA šA Monitor Where as now i need to keep the file as: "num", "Name" "num", "Name" Im trying.. and strugling to be able to add the values of two text boxs (one for the number, one for the name) to the text file, and also sruggling to try and delete one record: For the deleting part.. a combo box holds the number or name part.. (from the code in this post) What im trying to do is have a user select a value from a combo box.. say the number.. and then click delete and the record be deleted Any help would be great, Thanks, -BP- |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > text file contents to combo box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|