Solved

Linking textbox to Progress Bar

Posted on 2007-11-20
9
353 Views
Last Modified: 2013-12-26
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
0
Comment
Question by:samandrew
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 20327583
Just put code in the text_changed event to update the progress bar to what you want.
0
 

Author Comment

by:samandrew
ID: 20329338
Hi

You mean like

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

??

Thanks
Andy
0
 
LVL 18

Expert Comment

by:JR2003
ID: 20329717

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
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:samandrew
ID: 20336115
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
0
 
LVL 18

Expert Comment

by:JR2003
ID: 20336810
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
0
 

Author Comment

by:samandrew
ID: 20338212
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
0
 
LVL 1

Accepted Solution

by:
Nash3181 earned 500 total points
ID: 20394417
try this one:

Private Sub txttotal_Change()
on error goto errhandler
    Dim i as double
    i = cdbl(txttotal.Text)
    if i <= Pbar1.Max Then
        Pbar1.Value = cdbl(txttotal.Text)
    Else
        Pbar1.Value = Pbar1.Max
    End If
errhandler:
End Sub
0
 

Author Comment

by:samandrew
ID: 20396799
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
0
 
LVL 1

Expert Comment

by:Nash3181
ID: 20469107
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....
0

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month6 days, 7 hours left to enroll

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question