|
-
Sep 30th, 2004, 05:24 PM
#1
Thread Starter
Hyperactive Member
public subs
Im working on a sub to use for part of this program im working on, but ran into this problem:
In form3 I have a picture box where when the clicks on it it calls for the sub that is located in a module.
VB Code:
Private Sub p1_Click()
selectplanet (p1)
End Sub
Then in the module I have this code:
VB Code:
Public Sub selectplanet(pbox As PictureBox)
msgbox pbox
End Sub
but then when i run the project and click on picturebox p1, it says object required and highlights the selectplanet (p1) line, any suggestions?
Last edited by Narfy; Sep 30th, 2004 at 07:01 PM.
-
Sep 30th, 2004, 05:29 PM
#2
Either
Call selectplanet (p1)
or
selectplanet p1
-
Sep 30th, 2004, 05:31 PM
#3
"msgbox pbox"
can that be done? what are you trying to achieve?
EDIT: seems it can and Marty pointed out the solution...
That is with all subs, if you use Call you have to put the arguments in brackets, if not you CANT put them in brackets
-
Sep 30th, 2004, 06:06 PM
#4
That is with all subs, if you use Call you have to put the arguments in brackets, if not you CANT put them in brackets
That is not entirely correct. Using "brackets" without the CALL keyword means to pass the parameter ByVal.
However, if you pass an Object (or control) ByVal, VB will pass the object's default property.
-
Sep 30th, 2004, 06:50 PM
#5
Thread Starter
Hyperactive Member
Originally posted by baja_yu
"msgbox pbox"
can that be done? what are you trying to achieve?
EDIT: seems it can and Marty pointed out the solution...
That is with all subs, if you use Call you have to put the arguments in brackets, if not you CANT put them in brackets
I just put in msgbox pbox because i have like 50 lines of code that goes inside of the sub, so to make my post shorter i just replaced everything with the msgbox
yep, thanks for all the help, it is working perfectly now
Last edited by Narfy; Sep 30th, 2004 at 06:53 PM.
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
|