Results 1 to 2 of 2

Thread: Create your Own Progress Bar

  1. #1

    Thread Starter
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Create your Own Progress Bar

    I found this code on Tripod and it works pretty well:

    VB Code:
    1. 'This code will make a percentage progress bar, like those in installation programs.
    2. 'Add 1 PictureBox and 1 CommandButton to your form.
    3. 'Set The PictureBox DrawMode property to 6 - Invert.
    4. 'Insert the following code to your form:
    5.  
    6. Sub PerCnt(iNewValue As Integer)
    7. If iNewValue > 100 Or iNewValue < 0 Then
    8. Beep
    9. Exit Sub
    10. End If
    11. Picture1.Cls
    12. Picture1.FontSize = 12
    13. Picture1.ScaleMode = 0
    14. Picture1.ScaleWidth = 100
    15. Picture1.ScaleHeight = 10
    16. Picture1.CurrentY = 2
    17. Picture1.CurrentX = Picture1.ScaleWidth / 2 - (Picture1.ScaleWidth / 15)
    18. Picture1.Print Str(iNewValue) & "%"
    19. Picture1.Line (0, 0)-(iNewValue, Picture1.ScaleHeight), Picture1.FillColor, BF
    20. End Sub
    21.  
    22. Private Sub Command1_Click()
    23. Dim a As Long
    24. Dim b As Long
    25.  
    26. For a = 1 To 100
    27.     PerCnt CInt(a)
    28.     For b = 1 To 20000000: Next b
    29. Next a
    30. End Sub
    Last edited by Mark Gambo; Jul 1st, 2005 at 10:30 AM.
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  2. #2
    Frenzied Member wiz126's Avatar
    Join Date
    Jul 2005
    Location
    Mars,Milky Way... Chit Chat Posts: 5,733
    Posts
    1,080

    Re: Create your Own Progress Bar

    The way u changed it from the website made it uncontroable. since your variable r not set-able if the % didn't get to 100% if might cuss the application to frize or even might make u restart the computer. u might want to make some veriables like a timer to do it for u

    let x b the % for your picutre
    just set your timer interval to anywhere from 50 to 100 just for the hack of it



    VB Code:
    1. Dim x As Integer
    2. Sub PerCnt(iNewValue As Integer)
    3. If iNewValue > 100 Or iNewValue < 0 Then
    4. Beep
    5. Exit Sub
    6. End If
    7. Picture1.Cls
    8. Picture1.FontSize = 12
    9. Picture1.ScaleMode = 0
    10. Picture1.ScaleWidth = 100
    11. Picture1.ScaleHeight = 10
    12. Picture1.CurrentY = 2
    13. Picture1.CurrentX = Picture1.ScaleWidth / 2 - (Picture1.ScaleWidth / 15)
    14. Picture1.Print Str(iNewValue) & "%"
    15. Picture1.Line (0, 0)-(iNewValue, Picture1.ScaleHeight), Picture1.FillColor, BF
    16. End Sub
    17. Private Sub Form_Load()
    18. Timer1.Enabled = True
    19. End Sub
    20.  
    21. Private Sub Form_Unload(Cancel As Integer)
    22. Timer1.Enabled = False 'make the timer stop so no error will happend
    23. End Sub
    24.  
    25. Private Sub Timer1_Timer()
    26. x = x + 1
    27. PerCnt CInt(x)
    28. End Sub

    Last edited by wiz126; Jul 25th, 2005 at 05:27 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width