Link to home
Start Free TrialLog in
Avatar of samandrew
samandrew

asked on

Linking textbox to Progress Bar

Hi
Can anyone show me how to link a value in a text box to a progress bar so as if the value changes in the text box so does the progress bar.  Also is it possible to display the % as displayed text inside the progress bar?.

Many Thanks
Andy
Avatar of JR2003
JR2003

Just put code in the text_changed event to update the progress bar to what you want.
Avatar of samandrew

ASKER

Hi

You mean like

If txttotal = >0 Then
txttotal.text = Pbar1.Value
Else
Pbar1.Value = Pbar1.Max

??

Thanks
Andy

Private Sub TextBox1_Change()
    Dim i as Long
    i = Val(Pbar1.Text)
    if i <= Pbar1.Max Then
        Pbar1.Value = Val(Pbar1.Text)
    Else
        Pbar1.Value = Pbar1.Max
    End If
End Sub
Hi
Sorry I need the progress bar to go down as i enter the number into my txtbox. Also do you know how i can display the % as text?

Many Thanks
Andy
Private Sub TextBox1_Change()
    Dim i as Long
    i = Val(txttotal.Text)
    if i <= Pbar1.Max Then
        Pbar1.Value = Val(txttotal.Text)
    Else
        Pbar1.Value = Pbar1.Max
    End If
End Sub
Hi

This doesnt seem to work for me!, firstly the progress bar seems to be adding the numbers, secondly I cannot display the percentage which is left. Please can you relook at the code.

Many Thanks
Andy
ASKER CERTIFIED SOLUTION
Avatar of Nash3181
Nash3181

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi Nash

Can you please give an example of how I can use this code on 2 progressbars, so if when the value reaches 0 in progressbar1 the value is deducted from progressbar2.

Many Thanks
Andy
On what event will the 2 progressbars decrease it's value?
You can try this as a guide:
1 Command Button
2 ProgressBar

Situation: everytime i press the command button the value in progressbar1 will decrease and whenever the value of progressbar reached 0, it will deduct value from progressbar2 and progressbar1 will start again with its max value.


Private sub command1_click()
On error goto errhandler
if progressbar2.value = 0 then
   exit sub
end if

progressbar1.value = progressbar1.value -1
if progressbar1.value <= 0 then
   progressbar2.value =  progressbar2.value - 1
   progressbar1.value = progressbar1.max
end if

errhandler:
End Sub

Hope this code can help you....