Results 1 to 9 of 9

Thread: Need Control Array For This, Vb.net

  1. #1

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256

    Need Control Array For This, Vb.net

    I am loading a form which has Eight comboBoxes, named ComboStation1, ComboStation2, ComboStation3, etc. In each combobox I have to add 118 City names. Since Vb.net doesn't support control arrays, and there is no event for add_handler to handle such a task, is this the only way to program that....

    VB Code:
    1. Private Sub Combostation1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    2.               comboSTATION1.Items.Add("Akron, OH"))
    3.               comboSTATION1.Items.Add("Albany, NY")
    4. End Sub

    and do that eight times. 8 * 118 = 944 lines of code to do such a simple task. IF ANYONE knows an easier way, i would greatly appreciate it.

    thanks,

    Jeff

  2. #2
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    This might make it slightly easier for you.

    Dim Cmbo as ComboBox = Ctype(sender,Combobox)

    Cmbo.Items.Add (City)

    It would be 1 * 118.

    If you had a list you could read in, it would be much easier. Are you hand typing in all the names?
    That which does not kill us, only makes us stronger.

  3. #3

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256
    that isn't working, could you explain that further....

    thanks

  4. #4
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    you can create a single function that takes a combo box as a parameter. Then what ever combobox you pass can be loaded.
    That which does not kill us, only makes us stronger.

  5. #5

    Thread Starter
    Registered User jkw119's Avatar
    Join Date
    Oct 2001
    Location
    Pittsburgh
    Posts
    256
    hey, thanks, i got it now... that is great..


    jeff

  6. #6
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    That may get ya down to 1* 118 anyway. Are you hardcoding the names in?
    That which does not kill us, only makes us stronger.

  7. #7
    Junior Member
    Join Date
    May 2002
    Posts
    22
    I don,t know all the facts of what your doing,but maybe creating text files migt be an idea.100 something values seems like a
    lot to throw in a combbox..You could
    create a module to write a file and a module to read one and
    make changes if necessary,but I dont have a clue about the
    application youre writing.I,ll just go back to my beer.
    All The Best
    tonyf

  8. #8
    Addicted Member wolfofthenorth's Avatar
    Join Date
    Jan 2001
    Location
    Tatooine
    Posts
    169
    I agree. I think it would be better in the long run to have the variables in a text file, Excel Spreadsheet, or Database. You could make changes to them without having to recomplie or change any code. You may also find a use for them within another application.
    That which does not kill us, only makes us stronger.

  9. #9
    Junior Member
    Join Date
    May 2002
    Posts
    22

    control arrays

    What was interesting was the idea of using
    parameters with the combobox.That would be a
    way to do all that control arrays can do.
    tonyf

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