اذهب الي المحتوي
أوفيسنا

التأكد من تنسيق التاريخ


Akram Galal

الردود الموصى بها

لسادة الأفاضل أعضاء المنتدى
كل عام وأنتم بخير
أريد عمل فورمة بها عدد 1 TextBox

وكود يقوم بالتأكد من أن تنسيق التاريخ الموجود في TextBox1 مطابق للتنسيق YYYY/MM/DD

واذا لم يكن مطابق يظهر رسالة تفيد ذلك 

ولكم جزيل الشكر

رابط هذا التعليق
شارك

جرب هذا الكود

Dim dDate As Date
Private Sub CommandButton1_Click()
    Sheet1.Range("A1").Value = dDate
End Sub
 
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    If Mid(TextBox1.Value, 4, 2) > 12 Then
        MsgBox "Invalid date, please re-enter", vbCritical
        TextBox1.Value = vbNullString
        TextBox1.SetFocus
        Exit Sub
    End If
     
    dDate = DateSerial(Year(Date), Month(Date), Day(Date))
    TextBox1.Value = Format(TextBox1.Value, "dd/mm/yyyy")
    dDate = TextBox1.Value
End Sub

 

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information