Link to home
Start Free TrialLog in
Avatar of CRAZY
CRAZY

asked on

CLICK EVENT HELP NEEDED FAST!!!!!

I have a menu wich contains a submenu

Help --> Motive -- About , 1 , 2 , 3 , 4 , etc... 22

I have the items About, 1 , 2 , 3 , etc all in a menu control array
because I want to be able to click on one of them and FormHelp comes up and displays a message in its text box related to the item clicked.

all of the items are called m1

However, I am having trouble finding the property which designates the item clicked m1(x) as being clicked.
For example if I click About, i want the m1(0) string to come up, but if I click 1, I want the m1(1) caption to come up.
Heres what I have...

Form1:


Private Sub m1_Click(Index As Integer)

If Index = 0 Then
m1(0).Caption = m1(0).Caption
End If
 
If Index = 1 Then
m1(1).Caption = m1(1).Caption
End If


'For i = 0 To 11
 ' If (m1(Index).Index = i) Then
 '   m1(i).Caption = m1(Index).Caption
 '   Exit For
 ' End If
'Next i

frmHelp.Show

end sub



FormHelp:

Private Sub Form_Load()

'motiv(x) is a global variable as string each containing different
'text sentances

For i = 0 To 11
   
   Select Case frmForm1.m1(i).Caption
 'I used caption because I thought it would work
 'with some previous code but it doesnt tell the form which
 ' menu item in the menu item array was clicked

       Case "About"
        txtHelp.Text = motiv(0)
        Exit For
       Case "1"
        txtHelp.Text = motiv(1)
        Exit For
       Case "2"
        txtHelp.Text = motiv(2)
        Exit For
       Case "3"
        txtHelp.Text = motiv(3)
        Exit For
       Case "4"
        txtHelp.Text = motiv(4)
        Exit For
       Case "5"
        txtHelp.Text = motiv(5)
        Exit For
       Case "6"
        txtHelp.Text = motiv(6)
        Exit For
       Case "7"
        txtHelp.Text = motiv(7)
        Exit For
       Case "8"
        txtHelp.Text = motiv(8)
        Exit For
       Case "9"
        txtHelp.Text = motiv(9)
        Exit For
       Case "11"
        txtHelp.Text = motiv(11)
        Exit For
       Case "22"
        txtHelp.Text = motiv(12)
        Exit For
    End Select
Next i
End Sub



Thank you to anyone who can help me
Avatar of dosyl
dosyl

Hi, why do you write the same thing:
m1(0).Caption = m1(0).Caption
m1(0).Caption will always = itself.
Avatar of Éric Moreau
The "index" returns the value of the selected menu item.

Private Sub m1_Click(Index As Integer)

msgbox m1(index).caption
frmHelp.Show

end sub



Do this:

                 Private Sub m1_Click(Index As Integer)

                 frmHelp. txtHelp.Text = motiv(Index)
                 frmHelp.Show

                 end sub
Avatar of CRAZY

ASKER

Dalin had the right answer.
I was going to do that but for some reason I thought that you couldnt set the txtHelp.text property until the form was loaded and that after the form is loaded you couldnt set the text property using the m1_click event.

Thanks a lot Lock the question if u want points
You can accept dalin comment even if it is not locked as an answer.

Check to the right of the "Comment" word, you should see a "accept as an answer".
Make sure your submenu is index (ie if you are loading it dynamically with only one to start, make sure it is indexed) - then you will be able to refer to the index.

ASKER CERTIFIED SOLUTION
Avatar of Dalin
Dalin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial