VB Code:
  1. Private Function Laser(picBild As PictureBox, StartX As Integer, StartY As Integer, StandLeft As Integer, StandRight As Integer, sFarbe As String)
  2.  
  3. Dim iZahl, iZahl2 As Integer
  4. Dim sFarbe2 As String
  5.  
  6. Me.ScaleMode = vbPixels
  7.  
  8. With picBild
  9. .ScaleMode = vbPixels
  10. .AutoRedraw = True
  11. End With
  12.  
  13. For iZahl2 = 0 To picBild.ScaleWidth
  14. For iZahl = 0 To picBild.ScaleHeight
  15. sFarbe2 = picBild.Point(iZahl2, iZahl)
  16. Line (StartX, StartY)-(StandLeft + iZahl2, StandRight + iZahl), sFarbe2
  17.  
  18. Next
  19. Line (StartX, StartY)-(StandLeft + iZahl2, StandRight + picBild.ScaleHeight), sFarbe
  20. Next
  21.  
  22. For iZahl2 = 0 To picBild.ScaleHeight
  23. Line (StartX, StartY)-(StandLeft + picBild.ScaleWidth, StandRight + iZahl2), sFarbe
  24. Next
  25.  
  26. End Function
  27.  
  28.  
  29. Private Sub Command1_Click()
  30. Laser Picture1, 700, 500, Picture1.left, Picture1.Top, Me.BackColor
  31.  
  32. End Sub

Here's the problem:

The form opens and I click on the command button. The first time the function draws the picture, it draws it at co-ordinates 1200, 60 which is nowhere near the picture! Every subsequent push of the button draws it in the correct location which is 80,60. Why is it pulling this phantom co-ordinate from for the first run?