Results 1 to 5 of 5

Thread: [RESOLVED] Index as Integer

  1. #1

    Thread Starter
    Hyperactive Member LawnNinja's Avatar
    Join Date
    Aug 2006
    Posts
    446

    Resolved [RESOLVED] Index as Integer

    Ok, I have a piece of code that works only is the "mouse over" section but I want the code to occur when you press a command button. Here is the code that I want toi happen when you click a command button.
    Code:
    Text6.Text = Picture4(Index).Left  'corner location
    Text7.Text = Picture4(Index).Top  'end
    
    Label17.Caption = X + Picture4(Index).Left 'For location on bg
    Label21.Caption = Y + Picture4(Index).Top 'end
    I think its because Index is not defined as an interger like it is in the "mouse over" section like so.
    Code:
     (Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    How do you get the code at the top to apply to a command button??? I tired adding the above code to the end of commandbutton press and you get errors.
    Last edited by LawnNinja; Jan 20th, 2007 at 11:28 AM.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Index as Integer

    You have a Control Array of PictureBoxes. Since the Mouse is "over" a certain PictureBox, it gives you the Index.

    Which PictureBox do you want to affect when you click the Command Button?

  3. #3

    Thread Starter
    Hyperactive Member LawnNinja's Avatar
    Join Date
    Aug 2006
    Posts
    446

    Re: Index as Integer

    VB Code:
    1. Text6.Text = Picture4(Index).Left  'corner location
    2. Text7.Text = Picture4(Index).Top  'end
    3.  
    4. Label17.Caption = X + Picture4(Index).Left 'For location on bg
    5. Label21.Caption = Y + Picture4(Index).Top 'end

    Do you mean my second picturebox that has the array with Picture4?

    If so it's Picture1.......

    Does anyone have any ideas?

  4. #4
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Index as Integer

    Create a module-level variable and store "Index" in there. Something like:
    VB Code:
    1. Option Explicit
    2.     Private myIndex As Integer
    3.  
    4. Private Sub Picture4_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    5.     myIndex = Index
    6. End Sub
    7.  
    8. Private Sub Command1_Click()
    9.     'use the "myIndex" here...
    10. End Sub

  5. #5

    Thread Starter
    Hyperactive Member LawnNinja's Avatar
    Join Date
    Aug 2006
    Posts
    446

    Re: Index as Integer

    Ok thanks gavio worked great. I had to do the same thing with the x and y also.

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