|
| 1 | +Imports System.Windows.Forms |
| 2 | + |
| 3 | +Public Sub Main |
| 4 | + Dim myfrm As New Form |
| 5 | + Dim oPB As New ProgressBar() |
| 6 | + ' add progress bar label e.g. xx of xx complete |
| 7 | + With oPB |
| 8 | + .top = 150 |
| 9 | + .left = 25 |
| 10 | + .Width = 150 |
| 11 | + .Minimum = 0 |
| 12 | + .Maximum = 100 |
| 13 | + .Value = 0 |
| 14 | + End With |
| 15 | + |
| 16 | + With myfrm |
| 17 | + .Text = "Progress Indicator" |
| 18 | + .TopMost = True |
| 19 | + .controls.add(oPB) |
| 20 | + .Show |
| 21 | + End With |
| 22 | + |
| 23 | + For i = oPB.Minimum To oPB.Maximum Step 5 |
| 24 | + 'Sleep |
| 25 | + Threading.Thread.Sleep(100) ' 100 milliseconds = 0.1 seconds |
| 26 | + oPB.Value = i |
| 27 | + Next |
| 28 | + |
| 29 | + MessageBox.Show("TaskComplete") |
| 30 | + myfrm.Close |
| 31 | + |
| 32 | + Exit Sub |
| 33 | + |
| 34 | +End Sub |
| 35 | + |
| 36 | +' |
| 37 | + |
| 38 | +'Public Class Form1 |
| 39 | +' |
| 40 | +' Private Sub Form1_Load(sender As Object, e As EventArgs) _ |
| 41 | +' Handles MyBase.Load |
| 42 | +' 'create two progress bars |
| 43 | +' Dim ProgressBar1 As ProgressBar |
| 44 | +' Dim ProgressBar2 As ProgressBar |
| 45 | +' ProgressBar1 = New ProgressBar() |
| 46 | +' ProgressBar2 = New ProgressBar() |
| 47 | +' 'set position |
| 48 | +' ProgressBar1.Location = New Point(10, 10) |
| 49 | +' ProgressBar2.Location = New Point(10, 50) |
| 50 | +' 'set values |
| 51 | +' ProgressBar1.Minimum = 0 |
| 52 | +' ProgressBar1.Maximum = 200 |
| 53 | +' ProgressBar1.Value = 130 |
| 54 | +' ProgressBar2.Minimum = 0 |
| 55 | +' ProgressBar2.Maximum = 100 |
| 56 | +' ProgressBar2.Value = 40 |
| 57 | +' 'add the progress bar to the form |
| 58 | +' Me.Controls.Add(ProgressBar1) |
| 59 | +' Me.Controls.Add(ProgressBar2) |
| 60 | +' ' Set the caption bar text of the form. |
| 61 | +' Me.Text = "my text here" |
| 62 | +' End Sub |
| 63 | +'End Class |
0 commit comments