Results 1 to 4 of 4

Thread: Picturebox problem

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Picturebox problem

    I have a form with a picturebox on the top that I am going to use as a "page header". The page header is going to be on multiple forms so would like to set its properties in one place instead of multiple places.

    In the form load of the form, I have:
    VB Code:
    1. Private Sub Form_Load()
    2.     PageDesign
    3. End Sub
    The picturebox is called picPageHeader. Now in the module, I have:
    VB Code:
    1. Public Sub PageDesign(picPageHeader As PictureBox)
    2.     With picPageHeader
    3.         .BackColor = RGB(187, 187, 187)
    4.     End With
    5. End Sub
    but when I bring up the form, I am given the following error message:
    Argument not optional
    When I click OK, I am then taken to the form load event of the form itself. What am doing wrong? Please advise and thanks in advance.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Picturebox problem

    Try this...

    Code:
    Private Sub Form_Load()
        PageDesign picPageHeader 
    End Sub
    .
    .
    .
    Public Sub PageDesign(picPH As PictureBox)
        With picPH
            .BackColor = RGB(187, 187, 187)
        End With
    End Sub
    edit: I removed the ()'s around picPageHeader in the FORM_LOAD - I don't usually call sub/funcs without CALL or X= type syntax...
    Last edited by szlamany; Jan 7th, 2006 at 01:23 PM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3
    Fanatic Member vbasicgirl's Avatar
    Join Date
    Jan 2004
    Location
    Manchester, UK
    Posts
    1,016

    Re: Picturebox problem

    you have missed the picturebox argument

    PageDesign Form1.Picture1

    dont forget it would be a different form for each one.

    casey.

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

    Re: Picturebox problem

    When you call the PageDesign sub you you need to specify the picturebox as expected in the parameter, eg:

    PageDesign picPageHeader

    either that, or remove the parameter from the sub (assuming that it is in the form)

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