hallo,
ich möchte nach einer aktion eine msgbox nach 5 sekunden automatisch wieder schliessen lassen. kann mir da jemand weiterhelfen?
*~dug, mib~*
Einfachste Möglichkeit…
Eigene Msgbox bauen,
ist in VB ein 10 Zeiler(oder max 20 , dann kannst du in der Anzeigemethode mit übergeben, wie lange die maximal da sein soll und die Form dann über einen Timer schließen…
Ralph
hallo Ralph,
dank für deine antwort… könntest du mir zu dem thema timer mal unter die arme greifen? wie baust du den auf… format (time, hh:mm:ss ) ist mir bekannt… beim rest ist nebel…
*~dug~* mib
[Bei dieser Antwort wurde das Vollzitat nachträglich automatisiert entfernt]
Hier der Code…
Hi,
das Layout der Form ist nach eigenen Wünschen anzupassen:
(Es existieren 2 Knöpfe, ein Timer und ein Label, siehe Quelltext)
Ralph
Option Explicit
Private WaitForAction As Boolean
Private Action As tAction
Public Enum tAction
acNoAction = 0
acCommand1 = 1
acCommand2 = 2
acTimer = 3
End Enum
Private Sub cmdCommand1\_Click()
WaitForAction = False
Action = acCommand1
End Sub
Private Sub cmdCommand1\_KeyPress(KeyAscii As Integer)
If (Chr$(KeyAscii) = "2") And (cmdCommand2.Visible) Then
cmdCommand2\_Click
Else
cmdCommand1\_Click
End If
End Sub
' Shows Messagebox
Public Function showMessage(ByVal Message As String, ByVal title As String, ByVal button1Caption As String, ByVal button2Caption As String, Optional timerSec As Long = 60) As tAction
Debug.Assert timerSec "" Then
cmdCommand1.Visible = True
cmdCommand1.Caption = "&1: " & button1Caption
Else
cmdCommand1.Visible = False
End If
If button2Caption "" Then
cmdCommand2.Visible = True
cmdCommand2.Caption = "&2: " & button2Caption
Else
cmdCommand2.Visible = False
End If
Timer1.Interval = timerSec \* 1000
Timer1.Enabled = True
Me.Show
While WaitForAction
DoEvents
Wend
Timer1.Enabled = False
showMessage = Action
Unload Me
End Function
Private Sub cmdCommand2\_Click()
WaitForAction = False
Action = acCommand2
End Sub
Private Sub cmdCommand2\_KeyPress(KeyAscii As Integer)
If (Chr$(KeyAscii) = "1") And (cmdCommand1.Visible) Then
cmdCommand1\_Click
Else
cmdCommand2\_Click
End If
End Sub
Private Sub Form\_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If WaitForAction Then Cancel = True
End Sub
Private Sub Timer1\_Timer()
Timer1.Enabled = False
WaitForAction = False
Action = acTimer
End Sub
In eine Form packen und aufrufen mit frmmsg.showmessage(…)
Wenn die MsgBox auch länger als 65 Sekunden auf sein soll, dann den Timer auf 1 Sek stellen, bei ShowMessage die Zeit speichern, oldTime=now und bei timer nur reagieren, wenn csng(oldtime)+anzsekunden