how to switch between picture boxes by the name ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sbtunx
    New Member
    • Feb 2011
    • 8

    #1

    how to switch between picture boxes by the name ?

    we have two picture boxes by names of "pic1" and "pic2"
    we want to maintain parameters "isize" and "jsize" with parameter "picnum".
    the code dosent work whats the problem?
    Code:
    dim picnum as string
    if a=1 then
    picnum=pic1
    else 
    picnum=pic2
    end if
    
    With picnum
    isize = .Height
    jsize = .Width
    end with
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    The default property for "pic1" and "pic2" is the picture of the box.
    so you can't set a var "picnum" (that by the way a string ??? is and not an integer) can't contain a picture.
    How can "picnum" (a string) have a .width and .height ???

    Suggestion: always set the properties like:
    Picture1.pictur e
    Text1.text
    ....

    Comment

    • sbtunx
      New Member
      • Feb 2011
      • 8

      #3
      thank you but "pic1" and "pic2" are the "name property" of every picture box not the name of picturs. and yes i dont know really what should be "picnum" a string ...an object...or other. i will thank you more if you modify this code

      Comment

      • Guido Geurs
        Recognized Expert Contributor
        • Oct 2009
        • 767

        #4
        This is the code for placing the width and height of 2 pictures in a label via a var PICNUM:
        Code:
        Private Sub ComPic1_Click()
        Dim PICNUM As StdPicture
           Set PICNUM = Picture1.Picture
           LabelWidth.Caption = "Width = " & PICNUM.Width
           LabelHeight.Caption = "Height = " & PICNUM.Height
        End Sub
        
        Private Sub ComPic2_Click()
        Dim PICNUM As StdPicture
           Set PICNUM = Picture2.Picture
           LabelWidth.Caption = "Width = " & PICNUM.Width
           LabelHeight.Caption = "Height = " & PICNUM.Height
        End Sub

        Comment

        Working...