Results 1 to 6 of 6

Thread: menu arrays

  1. #1
    scoutt
    Guest

    menu arrays

    It seems that I have reached my limit of controls on a form. I know how to make the menu arrays in the menu editor but I am not sure on how to make the code that checks to see which menu array was click on.

    can anybode give me an example on how to do this?

    for example
    I have a mnuItem() 0 to 3

    I would like to know how to detect to see if I clicked on mnuItem(2).

    would I use the select case or something.

    TIA

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I never wrote a program before that had a control array of menu items, but with a little experimentation I found that you can just to this
    Code:
    Private Sub mnuItem_Click(Index As Integer)
    MsgBox Index ' You could use a Case statement here
    End Sub
    BTW I had to manually add the "Index As Integer".

  3. #3
    scoutt
    Guest
    I was close. I had
    VB Code:
    1. Private Sub mnuItem_Click(I As Integer)
    2. End Sub
    but when I click on the mnuItem it needs to load a text file into a textbox.
    so could I do something like this
    VB Code:
    1. Private Sub mnuItem_Click(I As Integer)
    2. select case mnuItem(I)
    3. case 0
    4. for i = 0 to 3
    5.    If mnuItem(i) = 0 then
    6.    open("c:\text.txt")
    7.   'call sub to load into textbox
    8.  End If
    9. case 1
    10.    If mnuItem(i) = 1 then
    11.    open("C:\text.txt")  
    12.   'call sub to load into textbox
    13.  End If
    14.  'and so on
    15. Next I
    16. End Sub
    I think I tried that and it didn't work. or did I do something wrong?

  4. #4

  5. #5
    scoutt
    Guest
    Thanks Martin, I will get back to you on this.

  6. #6
    scoutt
    Guest
    thanks Martin, that worked like a charm. and too think I was so close.

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