Results 1 to 7 of 7

Thread: How to Add items in combo box

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    honolulu, HI USA
    Posts
    37

    Talking

    Okay, the Title isn't specific enough but I will specify myself here.

    I am making this program (well I already made it... Finished) Anyways It has a Combo box with all content and stuff, then when you click on it it will bring up texts and stuff in a text box! What I'm wondering is, if you save a File that you have edited in that txtBox(textbox) and add that file in the cboBox(combobox) so when the user clicks on that cbobox the content of that file appears in the text box. I know the Command cboBox.Additem (Whatever) but you see, when you unload the Program, that item will be gone.... and forever lost, I want it to be there permanently, forever...... How can I do this, Can anyone show me an example code?

    Thanxx!
    Dim VB as MyLife
    if VB = True then
    Load MyLife
    Else
    Unload MyLife
    End
    End If

  2. #2
    Guest

    Thumbs up Ahhhhhh.............how about at form load event

    something like

    cboThing.Clear
    do
    'selection or whatever
    cboThing.AddItem Whatever
    'exit do command here
    loop
    cboThing.ListIndex = 0

    Whats meant to go in the combo??????

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    honolulu, HI USA
    Posts
    37

    Unhappy Guess I wasn't specific enough huh?

    Well, here it goes I will explain it code to code.

    Okay.....
    I have this program..... its like this

    Code:
    Private Sub Form_Load()
    
    cboListBox.AddItem "Item 1"
    cboListBox.AddItem "Item 2"
    
    End Sub
    
    Private Sub cboListBox_Click()
    
    If cboListBox.Text = "Item 1" Then
    txtContent.Text = "This is Item 1" & VbCrLf & "Got any problem with that?"
    End If
    If cboListBox.Text = "Item 2" Then
    txtContent.Text = "This is Item 2" & VbCrLf & "Don't you think this whole thing is lame?"
    End If
    
    End Sub
    So, if I want to make a new one which will be:

    Code:
    Private Sub cmdNew_Click()
    
    cboListBox.AddItem "Item 3"
    txtContent.Text = "This is Item 3 now!" & VbCrLf & "Uhhh.... Item 3?"  ' The Content
    
    'Probably put a saving code here!
    End Sub
    so, what Im trying to explain here is how can I save that "Item 3" and Its Content, so the next time I can run a code to load the damn thing......... if you still don't get it....... I will let you see the code, or the program...... shees!

    THANXX!
    Dim VB as MyLife
    if VB = True then
    Load MyLife
    Else
    Unload MyLife
    End
    End If

  4. #4
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    ?

    Is this what you're after ?

    Code:
    Option Base 1
    
    Private Const NUM_ITEMS = 3
    Private arrValues(NUM_ITEMS, NUM_ITEMS) As String
    
    Private Sub cboListBox_Click()
    
    Dim intTemp As Integer
    
    intTemp = cboListBox.ListIndex + 1
    
    txtContent.Text = "This is " & arrValues(intTemp, 1) & ", " & arrValues(intTemp, 2)
    
    End Sub
    
    Private Sub Form_Load()
    
    Init_Array
    
    For intcount = 1 To UBound(arrValues)
    
        cboListBox.AddItem arrValues(intcount, 1)
    
    Next intcount
    
    End Sub
    
    Public Sub Init_Array()
    
    arrValues(1, 1) = "Item 1"
    arrValues(1, 2) = "Got any problem with that?"
    arrValues(2, 1) = "Item 2"
    arrValues(3, 2) = "Don't you think this whole thing is lame?"
    arrValues(3, 1) = "Item 3"
    arrValues(3, 2) = "Uhhh.... Item 3?"
    
    End Sub
    It would be easier to load these values from a file or the registry. Hard coding the value into the program means you will have to recompile it everytime you want to change the text.

    Have fun.
    That's Mr Mullet to you, you mulletless wonder.

  5. #5

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    honolulu, HI USA
    Posts
    37

    thank you!

    THANK YOU, I will try out the codes, I hope tha'll do it!
    Dim VB as MyLife
    if VB = True then
    Load MyLife
    Else
    Unload MyLife
    End
    End If

  6. #6
    Addicted Member
    Join Date
    May 1999
    Posts
    161

    Smile

    It seems to me that what you are trying to do needs to be using the registry.

    Don't even hard code your original items. Place them originaly in the registry. Then read everything out of it.

    Does that help ?...

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    honolulu, HI USA
    Posts
    37
    EXACTLY! I now found the solution! Thank you all for helping! phew!
    Dim VB as MyLife
    if VB = True then
    Load MyLife
    Else
    Unload MyLife
    End
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width