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

sum numbers

Posted on 2008-09-29
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

Question by:XK8ER
  • 2
  • 2
LVL 14

Expert Comment

ID: 22603015
try this
 While (CInt(txtPublic.Text) < 10000)
            txtPublic.Text = CInt(txtPublic.Text) + 1
 End While

Open in new window

LVL 13

Expert Comment

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

Expert Comment

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

Accepted Solution

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

LVL 13

Expert Comment

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.

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Write to a printer using vb.net 9 38
.NET 2008 VB and C# 6 39
Expression Evaluater 3 37
VB.net -  GroupBox / Panel DataBinding and behavior 3 12
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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