• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 145
  • Last Modified:

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
0
CRAZY
Asked:
CRAZY
1 Solution
 
dosylCommented:
Hi, why do you write the same thing:
m1(0).Caption = m1(0).Caption
m1(0).Caption will always = itself.
0
 
Éric MoreauSenior .Net ConsultantCommented:
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



0
 
DalinCommented:
Do this:

                 Private Sub m1_Click(Index As Integer)

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

                 end sub
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
CRAZYAuthor Commented:
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
0
 
Éric MoreauSenior .Net ConsultantCommented:
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".
0
 
tommy_boyCommented:
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.

0
 
DalinCommented:
Thanks
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now