Computer Science Canada

VB Help- looping help

Author:  simon66 [ Wed Jan 07, 2009 5:26 pm ]
Post subject:  VB Help- looping help

hey i need help with my program.... besicly what I need is when my progressbar reaches 100% this will add the my textbox

"Your download is done... Enjoy!"
and I add this to my timer1
code:
if progressbar1.value = 100 then
text1.text = text1.text & "Your download is done... Enjoy!"
end if


but it loops
"Your download is done... Enjoy!"
"Your download is done... Enjoy!"
"Your download is done... Enjoy!"
"Your download is done... Enjoy!"
and it nevers stops.... here is the file. Once you press update it will say downloading... but dont worry I took out the code that downloads the file.

Author:  OneOffDriveByPoster [ Wed Jan 07, 2009 6:20 pm ]
Post subject:  Re: VB Help- looping help

I think you can stop the timer.

Author:  Vertico [ Wed Jan 07, 2009 6:30 pm ]
Post subject:  Re: VB Help- looping help

Can you show the portion of code your having problems with? (The processbar)
I'm not going to download it mostly because I have no clue what version your using, and it would require me to reboot my laptop in windows.

It sounds like your just not breaking out of the loop after you finish.

Author:  simon66 [ Wed Jan 07, 2009 6:57 pm ]
Post subject:  Re: VB Help- looping help

Vertico @ Wed Jan 07, 2009 6:30 pm wrote:
Can you show the portion of code your having problems with? (The processbar)
I'm not going to download it mostly because I have no clue what version your using, and it would require me to reboot my laptop in windows.

It sounds like your just not breaking out of the loop after you finish.


Im having problem making "Your download is done... Enjoy!" appears on my textbox when the progress bar reaches 100% but it loops saying "Your download is done... Enjoy!" like 1000 times.

Author:  Vertico [ Wed Jan 07, 2009 7:13 pm ]
Post subject:  Re: VB Help- looping help

simon66 @ Wed Jan 07, 2009 7:57 pm wrote:
Vertico @ Wed Jan 07, 2009 6:30 pm wrote:
Can you show the portion of code your having problems with? (The processbar)
I'm not going to download it mostly because I have no clue what version your using, and it would require me to reboot my laptop in windows.

It sounds like your just not breaking out of the loop after you finish.


Im having problem making "Your download is done... Enjoy!" appears on my textbox when the progress bar reaches 100% but it loops saying "Your download is done... Enjoy!" like 1000 times.


So you said in your OP post. Give some code so I can see it.

Author:  jbking [ Wed Jan 07, 2009 7:14 pm ]
Post subject:  Re: VB Help- looping help

You do realize what this does to the Text value, right?

code:
if progressbar1.value = 100 then
text1.text = text1.text & "Your download is done... Enjoy!"
end if


It is concatenatingn the message over and over and over again, which is what you are telling it to do. There should be some command like break, exit, or return that may work with the last option being what I'd recommend if you want the program to just stop running that part of the code.

Author:  simon66 [ Wed Jan 07, 2009 7:58 pm ]
Post subject:  Re: VB Help- looping help

this is my code "

code:

Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Form_Load()

End Sub

Private Sub Timer1_Timer()
If ProgressBar1.Value = 100 Then
ProgressBar1.Value = 100
Else
ProgressBar1 = Val(ProgressBar1) + Val(10)
End If
End Sub


I have a progressbar a textbox and a command button

Author:  unoho [ Thu Jan 08, 2009 1:07 am ]
Post subject:  RE:VB Help- looping help

hey how do you get the progressbar.
because i can't seem to find it.

and the problem with your code (most likely) is that you have to disable the timer once the progress bar reaches 100.

Author:  isaiahk9 [ Thu Jan 08, 2009 3:33 pm ]
Post subject:  RE:VB Help- looping help

You could just make a lable as yoru progress bar. In your timer go :

lblBar.Width = lblBar.Width + 5

And :

If lblBar.Width > 500 Then
MsgBox "It's done"

Author:  Silent Avenger [ Sun Jan 18, 2009 2:26 am ]
Post subject:  Re: VB Help- looping help

The easiest thing to do is disable the timer but if you can't do that because you're still using it for other functions you can declare a Boolean variable which is a true false variable which you can use to trigger the event you want.


: