Solved

sum numbers

Posted on 2008-09-29
5
175 Views
Last Modified: 2010-04-23
hello there,
I have this code and I would like to see the numbers increasing in the textbox from 0 to 1000 but it doesn't show that..
I only see 0 then when I click It takes a few seconds then I see 1000.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        While (txtPublic.Text < 10000)
            txtPublic.Text = txtPublic.Text + 1
        End While
    End Sub

Open in new window

0
Comment
Question by:XK8ER
  • 2
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Binuth
ID: 22603015
try this
 While (CInt(txtPublic.Text) < 10000)
            txtPublic.Text = CInt(txtPublic.Text) + 1
            System.Threading.Thread.Sleep(50)
            Application.DoEvents()
 End While

Open in new window

0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22603029
you have to use timer component if you want to update UI.
0
 
LVL 13

Expert Comment

by:kaylanreilor
ID: 22603036
Add txtPublic.Refresh() into the while loop after calculation.
0
 
LVL 13

Accepted Solution

by:
SameerJagdale earned 500 total points
ID: 22603039
just add            
Application.DoEvents() after the line:
txtPublic.Text = txtPublic.Text + 1

 
0
 
LVL 13

Expert Comment

by:kaylanreilor
ID: 22603114
But you don't need to process ALL the pending events in the WHOLE application at this stage ! You only need to refresh the targetted window.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

786 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