Tuesday, June 16, 2020

Checking the System Date format MDY or not


Private Sub cboMDYChecker_Click()
    Dim sp As String
    Dim intMonth As Integer
    sp = Application.International(xlDateSeparator)

    If IsDate(TextBox1.Value) Then
        If Application.International(xlMDY) Then
            Me.Caption = "MDY Application"
            intMonth = CInt(Split(TextBox1.Value, sp)(0))
            If intMonth > 12 Then
                Label2.Caption = "Day-Month-Year order"
            Else
                Label2.Caption = "Month-Day-Year order"
            End If
        Else
            Me.Caption = "DMY Application"
            intMonth = CInt(Split(TextBox1.Value, sp)(1))
            If intMonth > 12 Then
                Label2.Caption = "Month-Day-Year order"
            Else
                Label2.Caption = "Day-Month-Year order"
            End If
        End If
    End If
End Sub

Private Sub UserForm_Initialize()
    If Application.International(xlMDY) Then
        Me.Caption = "MDY Application"
    Else
        Me.Caption = "DMY Application"
    End If
End Sub

Private Sub cboCloseChecker_Click()
    Unload Me
End Sub

No comments:

Post a Comment

Hot Topics