Results 1 to 5 of 5

Thread: public subs

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Utah
    Posts
    397

    Resolved 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:
    1. Private Sub p1_Click()
    2.      selectplanet (p1)
    3. End Sub

    Then in the module I have this code:
    VB Code:
    1. Public Sub selectplanet(pbox As PictureBox)
    2.      msgbox pbox
    3. 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.

  2. #2

  3. #3
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989
    "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

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    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.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Utah
    Posts
    397
    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
  •  



Click Here to Expand Forum to Full Width