Results 1 to 5 of 5

Thread: combo1 combo2 sequential file

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2016
    Posts
    52

    combo1 combo2 sequential file

    iHi, I'm ontro


    n combo1 it loads me the data well where are the vegetables and fruits themes


    in the themes file there is the following

    fruits
    vegetables


    Code:
    Private Sub Form_Load()
    Dim strBuff As String
    Dim strArr() As String
     
    On Error GoTo Err_Handler
     
        Combo1.Clear
     
        'Open and load the ComboBox with the Text File
        Open App.Path & "\themes.txt" For Input As #1
              Do Until EOF(1)
                Line Input #1, strBuff
                Combo1.AddItem strBuff
              Loop
        Close #1
     
    Exit Sub
     
    Err_Handler:
        MsgBox "Number: " & Err.Number & vbCrLf & _
        "Description: " & Err.Description, vbOKOnly + vbInformation, "File I/O Error"
    End Sub


    in the fruit file there is the following


    fruits

    peach
    watermelon
    oranges
    cherries
    pears



    in the vegetables file there is the following


    vegetables

    potatoes
    tomatoes
    onions



    the problem in combo2
    has to read the data of vegetables and fruits of the combo1
    Thank you

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,817

    Re: combo1 combo2 sequential file

    Sounds like you need to add code to the combo1_click that will populate combo2 based on the selected item in combo1.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2016
    Posts
    52

    Re: combo1 combo2 sequential file

    as it would be in code to be able to read in sequential file in the combo1_click
    Thank you

  4. #4
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    694

    Re: combo1 combo2 sequential file

    In the click event of combo1, you can access the .Text of the clicked item.

    Use that to derive the file name, then read that into combo2 in exactly the same way as you read the "themes" file into combo1.
    (Remember to clear the items from Combo2 first).

    Regards, Phill W.

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2016
    Posts
    52

    Re: combo1 combo2 sequential file

    thanks phill.w
    issue resolved

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