title: Resizing a picture to a fixed size in vb6
body: <p>Im trying to create a function that resizes images and loads them to a picturebox...</p>
  
  <p>so far i've done this:</p>
  
  <pre><code>Function ResizeImage(Picture As ImageFile, Width As Integer, Height As Integer) As ImageFile
      Dim ratioWidth, ratioHeight, ratio As Double
      Dim newWidth, newHeight As Integer
      Dim img As ImageFile
      Set img = Picture
  
      'Calgulate AspectRatio
      ratioWidth = (Width / Picture.Width)
      ratioHeight = (Height / Picture.Height)
  
      'Choose the smaller ratio
      If ratioWidth &gt; ratioHeight Then
          ratio = ratioHeight
      Else
          ratio = ratioWidth
      End If
  
      'Calgulate newWidth and newHeight
      newWidth = Picture.Width * ratio
      newHeight = Picture.Height * ratio
  
      'Return resized image
      ResizeImage = img.ARGBData.Picture(newWidth, newHeight)
  End Function
  </code></pre>
  
  <p>function called as:</p>
  
  <pre><code>picResim.Picture = LoadPicture(PicturePath) 'Show picture first
  Set PrintImg = New ImageFile                'Create a background picture
  PrintImg.LoadFile PicturePath               'to process on
  picResim.Picture = ResizeImage(PrintImg, 40, 30) 'Show resized picture
  </code></pre>
  
  <p>but as you can see i need a heavy debug, what am i doing wrong how can i resolve this?</p>