فبا-اكسل :ينبثق مربع الرسالة الشرطية كل دقيقتين من الآن
-
20-12-2019 - |
سؤال
لقد كنت أحاول حل الأمور باستخدام NOW (التاريخ/الوقت) ولكني لم أنجح.
- Checkbox1 عندما يلتقط True الآن في textbox1.
من القيمة الموجودة في مربع النص 1، أحتاج كل دقيقتين إلى رسالة تذكير منبثقة مع موافق كإقرار حتى يصبح مربع الاختيار 2 صحيحًا.هل يمكن لأي شخص المساعدة في هذا المنطق والكود؟شكرًا.
Dim X1 As Date Dim X2 As Date Dim X3 As Date Dim X4 As Date Private Sub CheckBox1_Click() X1 = Now If CheckBox1.Value = True Then TextBox1.Value = Now Call function01 If CheckBox1.Value = False Then TextBox1.Value = Null End Sub Sub function01() X2 = "00:02:00" X3 = Now - X1 X4 = Format(X3, "hh:mm:ss") If CheckBox1.Value = True Then If X4 = X2 Then MsgBox "Prompt", vbOKOnly, "Time Keeper Tool Reminder" Else End If Else End If End Sub
المحلول
يمكنك استخدام ال OnTime
حدث بدلاً من حلقة.
قم بتغيير الكود الخاص بك إلى:
If CheckBox1.Value = True Then
TextBox1.Value = Now
schedulePopup
End If
وإلى الوحدة أضف:
Public Sub schedulePopup()
'// schedule popup
Application.OnTime Now + TimeValue("00:00:20"), "popupMessage", , True
End Sub
Public Sub popupMessage()
If Not YourUserForm Is Nothing Then
If YourUserForm.CheckBox1.Value = True Then
MsgBox "Time Keeper Tool Reminder"
'// schedule next
schedulePopup
End If
End If
End Sub
لا تنتمي إلى StackOverflow