Hi
I want below code to be written only once in Visual Basic Project.
Dim lSourceX As Long, lSourceY As Long
Dim lOldWidth As Long, lOldHeight As Long
Dim lNewWidth As Long, lNewHeight As Long
Picture1.AutoRedraw = True
Picture1.Picture = LoadPicture(App.Path & "\Images\O_0_" & tno & ".jpg")
Picture1.Width = Picture1.Picture.Width
Picture1.Height = Picture1.Picture.Height
Dim SrcWidth As Long, SrcHeight As Long
Dim DestWidth As Long, DestHeight As Long
Dim ScaleFactor As Double
Dim NewWidth As Long, NewHeight As Long
If Picture1.Picture Is Nothing Then
MsgBox "Please load an image into Picture1 first.", vbExclamation, "Error"
Exit Sub
End If
Picture1.ScaleMode = 3 ' Pixels
Picture2.ScaleMode = 3 ' Pixels
SrcWidth = Picture1.ScaleWidth ' 3400
SrcHeight = Picture1.ScaleHeight ' 1900
DestWidth = 196
DestHeight = 163
Dim SrcAspect As Double, DestAspect As Double
SrcAspect = SrcWidth / SrcHeight
DestAspect = DestWidth / DestHeight
If SrcAspect > DestAspect Then
ScaleFactor = DestWidth / SrcWidth
Else
ScaleFactor = DestHeight / SrcHeight
End If
NewWidth = 350 'CLng(SrcWidth * ScaleFactor)
NewHeight = 300 'CLng(SrcHeight * ScaleFactor)
Picture2.Width = DestWidth * Screen.TwipsPerPixelX
Picture2.Height = DestHeight * Screen.TwipsPerPixelY
Picture2.AutoRedraw = True
Picture2.Refresh
Picture2.Picture = Picture2.Image
Thanks