Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #2242 > unrolled thread
| Started by | Stl Mongo <stlmongo@sbcglobal.net> |
|---|---|
| First post | 2015-04-05 08:34 -0500 |
| Last post | 2015-04-08 10:51 +0100 |
| Articles | 7 — 5 participants |
Back to article view | Back to comp.lang.basic.visual.misc
A little help Stl Mongo <stlmongo@sbcglobal.net> - 2015-04-05 08:34 -0500
Re: A little help Ron Weiner <rw@domain.com> - 2015-04-05 11:14 -0400
Re: A little help Stl Mongo <stlmongo@sbcglobal.net> - 2015-04-05 12:46 -0500
Re: A little help mike <spamme9@gmail.com> - 2015-04-07 01:06 -0700
Re: A little help Michael Cole <noone@invalid.com> - 2015-04-08 08:11 +1000
Re: A little help Stl Mongo <stlmongo@sbcglobal.net> - 2015-04-07 17:24 -0500
Re: A little help Deanna Earley <dee@earlsoft.co.uk> - 2015-04-08 10:51 +0100
| From | Stl Mongo <stlmongo@sbcglobal.net> |
|---|---|
| Date | 2015-04-05 08:34 -0500 |
| Subject | A little help |
| Message-ID | <mfrdln$ic3$1@speranza.aioe.org> |
I have some code that I can't seem to get to work properly. What I want
to do is loop through an array of integers and display a string during
each iteration to a label. I also want a delay between each iteration.
So, get first number, display on label, wait, get second number added to
first, display both, and so on.
Right now, what I have seems to go through each iteration, but doesn't
display each. After the loop finishes (delay works) it displays the
final string on the label.
Here is my code for that section:
For i = 0 To (numDrawn - 1)
strResults += (arrNumbers(i).ToString + " ")
Me.lblResults.Text = strResults
watch.Start()
Do Until watch.ElapsedMilliseconds > 1000
Loop
watch.Reset()
Next
Can anyone help me get this to work as wanted?
Thanks,
Mongo
[toc] | [next] | [standalone]
| From | Ron Weiner <rw@domain.com> |
|---|---|
| Date | 2015-04-05 11:14 -0400 |
| Message-ID | <mfrjeh$jbk$1@dont-email.me> |
| In reply to | #2242 |
Try Me.lblResults.Text = strResults DoEvents() watch.Start() Rdub
[toc] | [prev] | [next] | [standalone]
| From | Stl Mongo <stlmongo@sbcglobal.net> |
|---|---|
| Date | 2015-04-05 12:46 -0500 |
| Message-ID | <mfrsd5$obb$1@speranza.aioe.org> |
| In reply to | #2243 |
On 4/5/2015 10:14 AM, Ron Weiner wrote: > Try > > Me.lblResults.Text = strResults > DoEvents() > watch.Start() > > Rdub Thanks for the help but that didn't do it either. I finally got it, I had to add lblResults.Refresh() in the loop and now it's fine. Mongo
[toc] | [prev] | [next] | [standalone]
| From | mike <spamme9@gmail.com> |
|---|---|
| Date | 2015-04-07 01:06 -0700 |
| Message-ID | <mg0370$1nk$1@news.albasani.net> |
| In reply to | #2244 |
On 4/5/2015 10:46 AM, Stl Mongo wrote: > On 4/5/2015 10:14 AM, Ron Weiner wrote: >> Try >> >> Me.lblResults.Text = strResults >> DoEvents() >> watch.Start() >> >> Rdub > > Thanks for the help but that didn't do it either. > I finally got it, I had to add lblResults.Refresh() > in the loop and now it's fine. > > Mongo DoEvents() should have worked. Your loop uses a lot of horsepower, yes? The sleep statement should let something else run while it waits.
[toc] | [prev] | [next] | [standalone]
| From | Michael Cole <noone@invalid.com> |
|---|---|
| Date | 2015-04-08 08:11 +1000 |
| Message-ID | <mg1kkv$fo0$1@dont-email.me> |
| In reply to | #2244 |
Stl Mongo formulated on Monday : > On 4/5/2015 10:14 AM, Ron Weiner wrote: >> Try >> >> Me.lblResults.Text = strResults >> DoEvents() >> watch.Start() >> >> Rdub > > Thanks for the help but that didn't do it either. > I finally got it, I had to add lblResults.Refresh() > in the loop and now it's fine. > > Mongo One thing that you should probably also do is note the version of VB that you are using. VB.Net and VB Classic (6 and below) are completely different beasts, and most questions herte are for VB6. Otherwise you are just asking for confusion... -- Michael Cole
[toc] | [prev] | [next] | [standalone]
| From | Stl Mongo <stlmongo@sbcglobal.net> |
|---|---|
| Date | 2015-04-07 17:24 -0500 |
| Message-ID | <mg1lf7$64t$1@speranza.aioe.org> |
| In reply to | #2246 |
On 4/7/2015 5:11 PM, Michael Cole wrote: > Stl Mongo formulated on Monday : >> On 4/5/2015 10:14 AM, Ron Weiner wrote: >>> Try >>> >>> Me.lblResults.Text = strResults >>> DoEvents() >>> watch.Start() >>> >>> Rdub >> >> Thanks for the help but that didn't do it either. >> I finally got it, I had to add lblResults.Refresh() >> in the loop and now it's fine. >> >> Mongo > > One thing that you should probably also do is note the version of VB > that you are using. VB.Net and VB Classic (6 and below) are completely > different beasts, and most questions herte are for VB6. > > Otherwise you are just asking for confusion... > I'm using .NET (VB 2012). The issue I was having was with the text on the label not showing during each iteration. By adding the Refresh() function I was able to fix that. I actually went back after earlier today and commented out the Refresh() and tried DoEvents() again and it worked that way also. I'm not sure why it didn't work before, but I'm sure it was my mistake. Thanks again for your help. Mongo
[toc] | [prev] | [next] | [standalone]
| From | Deanna Earley <dee@earlsoft.co.uk> |
|---|---|
| Date | 2015-04-08 10:51 +0100 |
| Message-ID | <mg2top$qge$1@speranza.aioe.org> |
| In reply to | #2247 |
On 07/04/2015 23:24, Stl Mongo wrote: > I'm using .NET (VB 2012). The issue I was having was with the text on > the label not showing during each iteration. By adding the Refresh() > function I was able to fix that. > > I actually went back after earlier today and commented out the Refresh() > and tried DoEvents() again and it worked that way also. I'm not sure why > it didn't work before, but I'm sure it was my mistake. > > Thanks again for your help. In summary, drawing (updated text or graphics) is normally only done when you explicitly ask for a redraw (with .Refresh) or the message pump is run (DoEvents). Most graphical operations just update internal state and set a flag saying "redraw required". This stops CPU being chewed up when something isn't actually visible. -- Deanna Earley (dee@earlsoft.co.uk, dee@doesnotcompute.co.uk) (Replies direct to my email address will be printed, shredded then fed to the rats. Please reply to the group.)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.basic.visual.misc
csiph-web