pass picture as parameter in function

User avatar
sal21
PlatinumLounger
Posts: 4351
Joined: 26 Apr 2010, 17:36

pass picture as parameter in function

Post by sal21 »

i can have picture1 or picture2....

Code: Select all

Private Sub LOAD_IMG(IMMAGINE)

    Set Picture1.Picture = NewLoadPicture("C:\Lavori_Vb6\BANDIERE\FLAG\country-flags-main\png1000px\" & IMMAGINE)

    Picture1.ScaleMode = 3
    Picture1.AutoRedraw = True
    Picture1.PaintPicture Picture1.Picture, _
                          0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
                          0, 0, Picture1.Picture.Width / 26.46, _
                          Picture1.Picture.Height / 26.46

    Picture1.Picture = Picture1.Image

End Sub
i call with:
Call LOAD_IMG(IMMAGINE)

how to pass in LOAD_IMG, also the picture as parameter, similar:

Call LOAD_IMG(IMMAGINE, here the second parameter)

User avatar
HansV
Administrator
Posts: 78412
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: pass picture as parameter in function

Post by HansV »

Code: Select all

Private Sub LOAD_IMG(IMMAGINE As String, CTRL As Image)
    With CTRL
        Set .Picture = NewLoadPicture("C:\Lavori_Vb6\BANDIERE\FLAG\country-flags-main\png1000px\" & IMMAGINE)
        .ScaleMode = 3
        .AutoRedraw = True
        .PaintPicture .Picture, _
            0, 0, .ScaleWidth, .ScaleHeight, _
            0, 0, .Picture.Width / 26.46, _
            .Picture.Height / 26.46
        .Picture = .Image
    End With
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4351
Joined: 26 Apr 2010, 17:36

Re: pass picture as parameter in function

Post by sal21 »

HansV wrote:
20 Oct 2022, 08:05

Code: Select all

Private Sub LOAD_IMG(IMMAGINE As String, CTRL As Image)
    With CTRL
        Set .Picture = NewLoadPicture("C:\Lavori_Vb6\BANDIERE\FLAG\country-flags-main\png1000px\" & IMMAGINE)
        .ScaleMode = 3
        .AutoRedraw = True
        .PaintPicture .Picture, _
            0, 0, .ScaleWidth, .ScaleHeight, _
            0, 0, .Picture.Width / 26.46, _
            .Picture.Height / 26.46
        .Picture = .Image
    End With
End Sub
:clapping:

User avatar
SpeakEasy
4StarLounger
Posts: 544
Joined: 27 Jun 2021, 10:46

Re: pass picture as parameter in function

Post by SpeakEasy »

I'm a trifle confused. Why try and write a whole new procedure to achieve something that the NewLoadPicture function I believe you were given on tek-tips (https://www.tek-tips.com/viewthread.cfm?qid=1819138) can already do: arbitrarily resize the picture.