arrays, comboboxes and frustration
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: arrays, comboboxes and frustration

  1. #1
    Join Date
    Nov 2005

    Angry arrays, comboboxes and frustration

    Here's a trick I need to do:
    I am writing a program that will print a string of three characters everytime I select something from a combobox. And I get frustrated, cause it does not work. Here's the code and the file I am using:
    'get the states list
    Set mFstate = mFSO.GetFile("c:\states.txt")
    Set mTstate = mFstate.OpenAsTextStream(ForReading)
    'string and integer declaration for the event combo box
    Dim strevent As String, indevent As Integer, nextevent(53, 2) As String
    Dim i As Integer, j As Integer
    'load the event list
        strevent = mTevent.ReadAll
        indevent = InStr(1, strevent, ",")
        i = 0
        While indevent <> 0 And i < 53
            j = 0
            nextevent(i, j) = Left$(strevent, indevent - 1)
            j = 1
            strevent = Right$(strevent, Len(strevent) - indevent)
            indevent = InStr(1, strevent, ",")
            nextevent(i, j) = Left$(strevent, indevent - 1)
            strevent = Right$(strevent, Len(strevent) - indevent)
            indevent = InStr(1, strevent, ",")
            cmb_event.AddItem (nextevent(i, 0))
            cmb_eventcode.AddItem (nextevent(i, 1))
            i = i + 1
    Now, everything I tried in order to get it printed, or stored in a variable (dim eve as string), it did not work. So what I want is that whenever the user selects something from the combobox, the appropriate 3 character string to be stored in that eve variable.
    Please help!
    Attached Files Attached Files

  2. #2
    Join Date
    Jun 2005
    JHB South Africa

    Re: arrays, comboboxes and frustration

    try this code. Just add it to your app
    Private Sub cmb_event_Click()
    Eve = Eve &" " & cmb_eventcode.list(cmb_event.ListIndex)
    End Sub
    with this code everytime a item is selected in Cmb_Event the relevant code in Cmb_eventcode will be added to the Eve string, with a space between each.

    Note: Eve must be defined at a global level (Under the Definitions area of your form).

    Hope This Helps You
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Nov 2005

    Thumbs up Re: arrays, comboboxes and frustration

    I'm in love with you!!!

    THANK YOU!!!
    You're my hero!

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center