|
-
Aug 30th, 2000, 05:41 PM
#1
Thread Starter
Member
I know I'll probably be stoned and thrown out of the forum for saying this but..
*coughIdon'tknowhowtouseaprogressbarcough*
umm
Can someone hook me up with an example of using a progress bar? I usually try to figure stuff out on my own but I don't know a thing about the control except how to put it on my form 
Don't Stone me please!!
-Brad
-
Aug 30th, 2000, 05:43 PM
#2
Monday Morning Lunatic
Code:
Private Sub Form_Load()
Me.Show
ProgressBar1.Min = 0
ProgressBar1.Max = 100
For i = 0 to 100
ProgressBar1.Value = i
DoEvents
Next i
End Sub
Put that into your form and watch...
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 30th, 2000, 05:44 PM
#3
Hyperactive Member
Code:
pbProgress.Min = 0
pbProgress.Max = 100
pbProgress.Value = 0
'Do something
pbProgress.Value = 10
pbProgress.Refresh
'Do something more
pbProgress.Value = 20
pbProgress.Refresh
-
Aug 30th, 2000, 05:49 PM
#4
Thread Starter
Member
Sweetness
Thanx for the nfo
Have you heard about a gradient progress bar? i have a copy of the code somewhere on this thing..
-
Aug 30th, 2000, 05:52 PM
#5
Monday Morning Lunatic
Yep. I think I wrote one a while ago.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 30th, 2000, 05:54 PM
#6
A progressbar can also measure action. Say for example, opening a text file:
Code:
x = FileLen("C:\file.txt")
ProgressBar1.Min = 0
ProgressBar1.Max = x
For i = 0 To x
ProgressBar1.Value = i
Next i
Open "C:\file.txt" For Input As #1
Text1.Text = Input$(LOF(1), 1)
Close #1
ProgressBar1.Value = ProgressBar1.Max
-
Aug 30th, 2000, 06:07 PM
#7
Thread Starter
Member
How does that measure action
How would that measure action?>
wouldn't the program just run through the loop
jack the progress bar up to its max
THEN open the file and making sure to set it at max again??
-confused
-
Aug 30th, 2000, 06:08 PM
#8
_______
<?>
Code:
or you can make your own progress bar..
'example of a Picture1 bar using a picture box
'make a standard app and add a picture box called Picture1
'add a command button called Command1
'in the PublicSub DoPicture1 and use Form1 as formname
'cut and paste the code and run to see an example
'
'<<<<<<< Put this in a bas module >>>>>>>>
Option Explicit
'number of things to do ex..files to be backed up
Public intCounted As Integer
'
Public Sub DoPicture1(Percent)
'
' Percent is % of graph
'
Dim Work As Integer
Dim Num As String
'
Work = Int(Abs(Percent))
If Work > 100 Then Work = 100
'
With Form1.Picture1 '<<< With application form
.BackColor = vbWhite '<<< White background
If Not .AutoRedraw Then '<<< picture in memory ?
.AutoRedraw = True '<<< make one
End If
.Cls '<<< clear picture in memory
.ScaleWidth = 100 '<<< new scalemodus
.DrawMode = 10 '<<< not XOR Pen Modus
Num = Format$(Work, "###") + "% Completed"
.CurrentX = 50 - .TextWidth(Num) / 2 '<<< %age is Centered
.CurrentY = (.ScaleHeight - .TextHeight(Num)) / 2
Form1.Picture1.ForeColor = vbBlack '<<< Black text
Form1.Picture1.Print Num '<<< print percent
Form1.Picture1.Line (0, 0)-(Work, .ScaleHeight), vbBlue, BF
.Refresh '<<< show
End With
'
End Sub
Option Explicit
' <<<<<<<<<<<< event code for form >>>>>>>>>>>>>>>>>>>
Private Sub Command1_Click()
Dim intTotalCount As Integer
intTotalCount = 100 'whatever..use 1000 for this example
'print the line & increment the count
Dim i, copied
For i = 1 To 100
Print "This is a progress bar sample!"
copied = copied + 1 'increment for progress bar
Call DoPicture1(copied / intTotalCount * 100) 'progress bar set to 100
Next i
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 30th, 2000, 06:20 PM
#9
Bad example, here is a better one, it is used to make a progressbar for a Webbrowser.
Code:
Private Sub WebBrowser1_ProgressChange(ByVal Progress As Long, ByVal ProgressMax As Long)
On Error Resume Next
Progressbar1.Min = 0
Progressbar1.Max = ProgressMax
Progressbar1.Value = Progress
End Sub
Well, the example above will open a file. The Progressbar's Max size will become the Text file's size.
The Progressbar will start counting up to the file size. During this process, the file will be put into a text file. And finally, after it has finished, the progressbar's value is all filled in. Makes it look like it measures action. Sorry for giving the wrong information.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|