Results 1 to 7 of 7

Thread: Favorite Menu Problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2003
    Posts
    135

    Unhappy Favorite Menu Problem

    Ok ive coded an intire working editable favorite menu for my software now the problem im having is with the menu index im not quite sure how to get the menu index of which favorite was clicked on the menu.

    Private Sub favlistmenu_Click(Index As Integer)

    Dim thename As String
    Dim thefav As String


    thename = menu.favlistmenu(i).Caption
    thefav = ReadInI(thename, "address", "C:\Program Files\newproduct\favorites.ini")

    MsgBox thename
    MsgBox thefav

    End Sub

    thats my code and the problem is no matter what it keeps making thename the first one on the menu list instead of the one that was clicked how do i fix this problem anyone please?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    you mistyped...

    thename = menu.favlistmenu(index).Caption

  3. #3

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2003
    Posts
    135

    ty

    dur fiqures my mistake. Thought i could be used in replace of index. works perfect now
    thanks guys.

  5. #5
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Originally posted by Wokawidget
    Put:
    VB Code:
    1. Option Explicit
    At the top of your form and then try and run your code.
    This will tell you if you've mistyped any varibles incorrectly.

    Wooof
    Theres a thing in the VB Options that places this at the top of every code window automatically for you, forgot what it was called though

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Originally posted by Madboy
    forgot what it was called though
    Menu: Tool | Options | Editor and check the Require Variable Declaration.




    Bruce.

  7. #7
    Supreme User Madboy's Avatar
    Join Date
    Oct 2003
    Location
    England
    Posts
    3,253
    Thats the one

    I never use to use Option Explicit, but now i see the importance of it. I always make sure i use it now, least if you do what bruce said, then its easier to delete the Option Explicit then to type it, but i reccomend keeping it there, on the top of every code window

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