If I build a list into a combo box and create a method of adding to that list. Can the list be modified after compiling?
Printable View
If I build a list into a combo box and create a method of adding to that list. Can the list be modified after compiling?
you can make Text1 equal to whatever you want, and and it to your list. Is this what you mean?Code:Private Sub Command1_Click()
Combo1.AddItem Text1.Text
End Sub
I believe Crypt answered your question. Just be sure to set the combo box's style to "0"
YES!
So even after compiling I can permanently add things to the list dynamically?
well, not permanently, just for that run of your app, you would have to generate a file that saves your list contents, and then, open the file and load the list when you start the program...
Permanently - no. If you want to have a list of items that is not hard-coded, you must either store and retreive them from a database or a file or some other data storage method.
Here's something I just quickly wrote up
Code:Option Explicit
Private Sub Command1_Click()
Combo1.AddItem Combo1.Text
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim x As Integer
Open "C:\Test.txt" For Output As #1
For x = 0 To Combo1.ListCount - 1
Print #1, Combo1.List(x)
Next
Close #1
End Sub
Private Sub Form_Load()
Dim x As Integer
Dim strCombo As String
Open "C:\Test.txt" For Input As #1
Do Until EOF(1)
Line Input #1, strCombo
Combo1.AddItem strCombo
Loop
Close #1
End Sub