ProgressBars and Application.DoEvents : Applications « GUI Applications « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » GUI Applications » Applications 
15.1.1.ProgressBars and Application.DoEvents
ProgressBars and Application.DoEvents
Option Strict On
imports System
imports System.Drawing
imports System.Windows.Forms

public class ProgressBars : inherits Form

  dim pb as ProgressBar
  dim lbl as Label

  public sub New()
    Size = new Size(300,200)

    dim btn as new Button()
    btn.Parent = me
    btn.Text = "&Start"
    btn.Location = new Point(0,0)
    AddHandler btn.Click, AddressOf btn_OnClick

    lbl = new Label()
    lbl.Parent = me
    lbl.Size = new Size(100,23)
    lbl.Location = new Point(0,25)
    lbl.BorderStyle = BorderStyle.FixedSingle
    lbl.TextAlign = ContentAlignment.MiddleCenter
    lbl.Text = ""

    pb = new ProgressBar()
    pb.Parent = me
    pb.Location = new Point(070)
    pb.Size = new Size(40020
    pb.Minimum = 0      '  the default value
    pb.Maximum = 100    '  the default value
  end sub  '  close for constructor

  private sub btn_OnClick(ByVal sender as object,ByVal e as EventArgs)
    dim cntr as integer = 0
    pb.Value = 0
    pb.Step = 1
    for i as integer = to 100000
      cntr  = cntr + 1
      if cntr mod 100 then
        lbl.Text = cntr.ToString()
        pb.PerformStep()
        Application.DoEvents()
        System.Threading.Thread.Sleep(40)
      end if
    next
  end sub

  public shared sub Main() 
    Application.Run(new ProgressBars())
  end sub

end class
15.1.Applications
15.1.1.ProgressBars and Application.DoEventsProgressBars and Application.DoEvents
15.1.2.Applications.DoEventsApplications.DoEvents
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.