|
-
Jan 20th, 2007, 11:14 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Jan 20th, 2007, 11:18 AM
#2
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?
-
Jan 21st, 2007, 12:07 PM
#3
Thread Starter
Hyperactive Member
Re: Index as Integer
VB 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
Do you mean my second picturebox that has the array with Picture4?
If so it's Picture1.......
Does anyone have any ideas?
-
Jan 21st, 2007, 02:18 PM
#4
Re: Index as Integer
Create a module-level variable and store "Index" in there. Something like:
VB Code:
Option Explicit
Private myIndex As Integer
Private Sub Picture4_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
myIndex = Index
End Sub
Private Sub Command1_Click()
'use the "myIndex" here...
End Sub
-
Jan 27th, 2007, 06:37 PM
#5
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|