Wednesday, 7 March 2012

A Form with a Status Bar, Progress Bar and an Error Object

A status bar can be used to display several form and user key stats such as caps lock, scroll lock, INS key and to display the system time. A timer object is used to create an auto increment for the time object to be placed in the status bar.
time1 = Time + Timer1.Interval
time1 = Format(time1, "HH:MM:SS")
StatusBar1.Panels(6).Text = time1
A progress bar uses an increment value in a timer object to display form load progress.
Private Sub Timer2_Timer()
If ProgressBar1.Value < 10 Then
ProgressBar1.Value = ProgressBar1.Value + 1
ElseIf ProgressBar1.Value = 10 Then
ProgressBar1.Value = 0
Timer2.Enabled = False
ProgressBar1.Visible = False
End If
The error object traps errors in the form for an animation object:
'On Error GoTo FileOpenError
On Error Resume Next
Animation1.Open ("c:\Users\PC\Desktop\photos\MVI_1230.avi")
Animation1.AutoPlay = True
If Err Then
MsgBox Err.Description & vbCrLf & Err.Number
End If
Timer1.Enabled = True
MsgBox "Total Message"
FileOpenError:
MsgBox "The Avi file is not ok. Please Try Another File"
Option Explicit
Dim time1 As Date
'Dim sbr1 As sbrTime
Private Sub Form_Load()
time1 = Format(Time, "HH:MM:SS")
'Text1.Text = sbr1
With StatusBar1
.Panels.Remove 1
.Panels.Add 1, "my key", "Form 6", sbrText
.Panels(1).AutoSize = sbrSpring
.Panels(1).Text = Form4.Caption
'sbrTime = time1
.Panels.Add , , , sbrCaps
.Panels.Add , , , sbrNum
.Panels.Add , , , sbrIns
.Panels.Add , , , sbrScrl
.Panels.Add 6
End With
'On Error GoTo FileOpenError
On Error Resume Next
Animation1.Open ("c:\Users\PC\Desktop\photos\MVI_1230.avi")
Animation1.AutoPlay = True
If Err Then
MsgBox Err.Description & vbCrLf & Err.Number
End If
Timer1.Enabled = True
MsgBox "Total Message"
FileOpenError:
MsgBox "The Avi file is not ok. Please Try Another File"
End Sub
Private Sub Timer1_Timer()
time1 = Time + Timer1.Interval
time1 = Format(time1, "HH:MM:SS")
StatusBar1.Panels(6).Text = time1
Text1.Text = Time + Timer1.Interval
'Text1.Text = Format(Text1.Text, "HH:MM:SS")
'Text1.Text = FormatDateTime(Text1.Text, vbGeneralDate)
'Text1.Text = Format(time, "HH:MM:SS")
End Sub
Private Sub Timer2_Timer()
If ProgressBar1.Value < 10 Then
ProgressBar1.Value = ProgressBar1.Value + 1
ElseIf ProgressBar1.Value = 10 Then
ProgressBar1.Value = 0
Timer2.Enabled = False
ProgressBar1.Visible = False
End If
End Sub

No comments:

Post a Comment