I took a code who someone in the forum(Serge!) wrote and I tryed to made a OCX with it. I changed some stuff but when I try my new OCX I have an error and I can solve it.

This is the code
***add a timer1 and a picture1(autodraw to true)***


***********Module***********
VB Code:
  1. Public Sub DrawProgress(p_PictureBox As PictureBox, ByVal p_sngPercent As Single, p_lngBackColor As Long, p_lngForeColor As Long)
  2.     Dim strPercent As String
  3.     Dim intX As Integer
  4.     Dim intY As Integer
  5.     Dim intWidth As Integer
  6.     Dim intHeight As Integer
  7.    
  8.     strPercent = Format$(Int(p_sngPercent)) & "%"
  9.     intWidth = p_PictureBox.TextWidth(strPercent)
  10.     intHeight = p_PictureBox.TextHeight(strPercent)
  11.     intX = p_PictureBox.Width / 2 - intWidth / 2
  12.     intY = p_PictureBox.Height / 2 - intHeight / 2
  13.    
  14.     With p_PictureBox
  15.         .FillStyle = vbFSSolid
  16.         .BackColor = p_lngBackColor
  17.         .ForeColor = p_lngForeColor
  18.         .DrawMode = vbCopyPen
  19.        
  20.         .CurrentX = intX
  21.         .CurrentY = intY
  22.         p_PictureBox.Print strPercent
  23.         .DrawMode = vbNotXorPen
  24.     End With
  25.    
  26.     If p_sngPercent > 0 Then
  27.         p_PictureBox.Line (0, 0)-(p_PictureBox.Width * p_sngPercent / 100, p_PictureBox.Height), p_lngForeColor, BF
  28.     Else
  29.         p_PictureBox.Line (0, 0)-(p_PictureBox.Width, p_PictureBox.Height), p_lngBackColor, BF
  30.     End If
  31.     p_PictureBox.Refresh
  32. End Sub
*****************Form*****************
VB Code:
  1. Option Explicit
  2. Dim i As Integer
  3. Private Sub Form_Load()
  4.     Timer1.Interval = 50
  5. End Sub
  6.  
  7. Private Sub Timer1_Timer()
  8. theValue = value(i + 1)
  9. End Sub
  10.  
  11. Private Sub UserControl_Initialize()
  12. Picture1.Left = 0
  13. Picture1.Top = 0
  14. End Sub
  15. Private Sub UserControl_Resize()
  16. Picture1.Width = UserControl.Width
  17. Picture1.Height = UserControl.Height
  18. End Sub
  19. Function value(i As Integer)
  20.     If i = 100 Then
  21.         i = 0
  22.     End If
  23.     i = i + 1
  24.     DrawProgress Picture1, i, vbWhite, vbBlue
  25. End Function
  26. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  27. i = PropBag.ReadProperty("ProgressValue", 0)
  28. End Sub
  29. Public Property Get theValue() As String
  30. theValue = i
  31. End Property
  32. Public Property Let theValue(ByVal New_Value As String)
  33.     i = New_Value
  34.     PropertyChanged "ProgressValue"
  35.     theValue = value(i)
  36. End Property
  37. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  38.     Call PropBag.WriteProperty("ProgressValue", i, 0)
  39. End Sub

Any one can tell me what I have to change to make it work because it work 1 sec and than crash ?