Trancefreak
Mitglied
Hallo Leute habe heute ein kleines Programm geschrieben was eine status bar und eine progress bar hat jedoch brauche ich hilfe
und zwar wenn die progress bar leiste voll ist und den wert 10000000 erreicht*die progressbar* soll eine meldung kommen das der upload fertig ist dies habe ich wie folgt versucht
If ProgressBar1.Value = 10 Then
MsgBox "Upload komplett", , "Test"
End If
Die meldung kommt jedoch nicht oder habe ich es nur falsch eingefügt?
Dies ist der gesammte Quellcode vielleicht könnt ihr mir ja sagen wo man das einsetzt oder falls ich falsch liege welches der richtige code dafür ist!
Danke im vorraus!
Option Explicit
Private defProgBarHwnd As Long
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
'used to change progressbar colour
Private Const WM_USER = &H400
Private Const CCM_FIRST As Long = &H2000&
Private Const CCM_SETBKCOLOR As Long = (CCM_FIRST + 1)
'set progressbar backcolor in IE3 or later
Private Const PBM_SETBKCOLOR As Long = CCM_SETBKCOLOR
'set progressbar barcolor in IE4 or later
Private Const PBM_SETBARCOLOR As Long = (WM_USER + 9)
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Sub Form_Load()
Dim pnl As Panel
Dim btn As Button
Dim x As Long
'create statusbar
With StatusBar1
For x = 1 To 3
Set pnl = .Panels.Add(, , "", sbrText)
pnl.Alignment = sbrLeft
pnl.Width = 1800
pnl.Bevel = sbrInset
If x = 3 Then pnl.AutoSize = sbrSpring
If x = 1 Then pnl.Text = "Status"
Next
End With
Command2.Caption = "Start Trace "
With ProgressBar1
.Min = 0
.Max = 10000000
.Value = .Max
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
If defProgBarHwnd <> 0 Then
SetParent ProgressBar1.hwnd, defProgBarHwnd
End If
End Sub
Private Sub Command2_Click()
Dim cnt As Long
Dim tmp As String
tmp = StatusBar1.Panels(1).Text
StatusBar1.Panels(1).Text = "Progress ..."
For cnt = 1 To ProgressBar1.Max
ProgressBar1.Value = cnt
'needed to trap cancel click
DoEvents
Next
StatusBar1.Panels(1).Text = tmp
ProgressBar1.Value = 0
End Sub
Private Function AttachProgBar(pb As ProgressBar, _
sb As StatusBar, _
nPanel As Long, _
pading As Long)
If defProgBarHwnd = 0 Then
'change the parent
defProgBarHwnd = SetParent(pb.hwnd, sb.hwnd)
With sb
'adjust statusbar. Doing it this way
'relieves the necessity of calculating
'the statusbar position relative to the
'top of the form. It happens so fast
'the change is not seen.
.Align = vbAlignTop
.Visible = False
'change, move, set size and re-show
'the progress bar in the new parent
With pb
.Visible = False
.Align = vbAlignNone
.Appearance = ccFlat
.BorderStyle = ccNone
.Width = sb.Panels(nPanel).Width
.Move (sb.Panels(nPanel).Left + pading), _
(sb.Top + pading), _
(sb.Panels(nPanel).Width - (pading * 2)), _
(sb.Height - (pading))
.Visible = True
.ZOrder 0
End With
'restore the statusbar to the
'bottom of the form and show
.Panels(nPanel).AutoSize = sbrNoAutoSize
.Align = vbAlignBottom
.Visible = True
End With
End If
End Function
und zwar wenn die progress bar leiste voll ist und den wert 10000000 erreicht*die progressbar* soll eine meldung kommen das der upload fertig ist dies habe ich wie folgt versucht
If ProgressBar1.Value = 10 Then
MsgBox "Upload komplett", , "Test"
End If
Die meldung kommt jedoch nicht oder habe ich es nur falsch eingefügt?
Dies ist der gesammte Quellcode vielleicht könnt ihr mir ja sagen wo man das einsetzt oder falls ich falsch liege welches der richtige code dafür ist!
Danke im vorraus!
Option Explicit
Private defProgBarHwnd As Long
Private Declare Function SetParent Lib "user32" _
(ByVal hWndChild As Long, _
ByVal hWndNewParent As Long) As Long
'used to change progressbar colour
Private Const WM_USER = &H400
Private Const CCM_FIRST As Long = &H2000&
Private Const CCM_SETBKCOLOR As Long = (CCM_FIRST + 1)
'set progressbar backcolor in IE3 or later
Private Const PBM_SETBKCOLOR As Long = CCM_SETBKCOLOR
'set progressbar barcolor in IE4 or later
Private Const PBM_SETBARCOLOR As Long = (WM_USER + 9)
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Sub Form_Load()
Dim pnl As Panel
Dim btn As Button
Dim x As Long
'create statusbar
With StatusBar1
For x = 1 To 3
Set pnl = .Panels.Add(, , "", sbrText)
pnl.Alignment = sbrLeft
pnl.Width = 1800
pnl.Bevel = sbrInset
If x = 3 Then pnl.AutoSize = sbrSpring
If x = 1 Then pnl.Text = "Status"
Next
End With
Command2.Caption = "Start Trace "
With ProgressBar1
.Min = 0
.Max = 10000000
.Value = .Max
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
If defProgBarHwnd <> 0 Then
SetParent ProgressBar1.hwnd, defProgBarHwnd
End If
End Sub
Private Sub Command2_Click()
Dim cnt As Long
Dim tmp As String
tmp = StatusBar1.Panels(1).Text
StatusBar1.Panels(1).Text = "Progress ..."
For cnt = 1 To ProgressBar1.Max
ProgressBar1.Value = cnt
'needed to trap cancel click
DoEvents
Next
StatusBar1.Panels(1).Text = tmp
ProgressBar1.Value = 0
End Sub
Private Function AttachProgBar(pb As ProgressBar, _
sb As StatusBar, _
nPanel As Long, _
pading As Long)
If defProgBarHwnd = 0 Then
'change the parent
defProgBarHwnd = SetParent(pb.hwnd, sb.hwnd)
With sb
'adjust statusbar. Doing it this way
'relieves the necessity of calculating
'the statusbar position relative to the
'top of the form. It happens so fast
'the change is not seen.
.Align = vbAlignTop
.Visible = False
'change, move, set size and re-show
'the progress bar in the new parent
With pb
.Visible = False
.Align = vbAlignNone
.Appearance = ccFlat
.BorderStyle = ccNone
.Width = sb.Panels(nPanel).Width
.Move (sb.Panels(nPanel).Left + pading), _
(sb.Top + pading), _
(sb.Panels(nPanel).Width - (pading * 2)), _
(sb.Height - (pading))
.Visible = True
.ZOrder 0
End With
'restore the statusbar to the
'bottom of the form and show
.Panels(nPanel).AutoSize = sbrNoAutoSize
.Align = vbAlignBottom
.Visible = True
End With
End If
End Function
Zuletzt bearbeitet: