Private Sub val_date_exist_Click()
Dim strDate As String
Dim dt As Date
Dim I As Long
For I = 1 To MSHFlexGrid1.Rows - 1
strDate = Trim(MSHFlexGrid1.TextMatrix(I, 1))
dt = DateSerial(CInt(Mid(strDate, 1, 2)), CInt(Mid(strDate, 4, 2)), CInt(Mid(strDate, 7, 4)))
If strDate = Format(dt, "MM/DD/YYYY") Then
Else
MSHFlexGrid1.TextMatrix(I, 0) = MSHFlexGrid1.TextMatrix(I, 1) & " - " & "BAD DATE FORMAT"
End If
Next
'Auto column fit
Dim c As Long
Dim cell_wid As Single
Dim col_wid As Single
Dim z As Long
For c = 0 To MSHFlexGrid1.Cols - 1
col_wid = 0
For z = 0 To MSHFlexGrid1.Rows - 1
cell_wid = TextWidth(MSHFlexGrid1.TextMatrix(z, c))
If col_wid < cell_wid Then col_wid = cell_wid
Next z
MSHFlexGrid1.ColWidth(c) = col_wid + 120
Next c
End Sub
Private Sub val_date_exist_Click()
Dim strDate As String
Dim dt As Date
Dim I As Long
For I = 1 To MSHFlexGrid1.Rows - 1
strDate = Trim(MSHFlexGrid1.TextMatrix(I, 1))
If IsDate(strDate) Then
dt = DateSerial(CInt(Mid(strDate, 1, 2)), CInt(Mid(strDate, 4, 2)), CInt(Mid(strDate, 7, 4)))
'If strDate = Format(dt, "MM/DD/YYYY") Then
Else
MSHFlexGrid1.TextMatrix(I, 0) = MSHFlexGrid1.TextMatrix(I, 1) & " - " & "BAD DATE FORMAT"
End If
Next
'Auto column fit
Dim c As Long
Dim cell_wid As Single
Dim col_wid As Single
Dim z As Long
For c = 0 To MSHFlexGrid1.Cols - 1
col_wid = 0
For z = 0 To MSHFlexGrid1.Rows - 1
cell_wid = TextWidth(MSHFlexGrid1.TextMatrix(z, c))
If col_wid < cell_wid Then col_wid = cell_wid
Next z
MSHFlexGrid1.ColWidth(c) = col_wid + 120
Next c
End Sub
Private Sub val_date_exist_Click()
Dim lngRow As Long
For lngRow = 1 To MSHFlexGrid1.Rows - 1
MSHFlexGrid1.TextMatrix(lngRow, 1) = Format(MSHFlexGrid1.TextMatrix(lngRow, 1), "MM/DD/YYYY")
If Not IsDate(MSHFlexGrid1.TextMatrix(lngRow, 1)) Then
MSHFlexGrid1.TextMatrix(lngRow, 0) = "BAD DATE FORMAT"
End If
Next
End Sub
ASKER
ASKER
strDate = MSHFlexGrid1.TextMatrix(lngRow, 1)
If CDate(strDate) <> DateSerial(Right(strDate, 4), Left(strDate, 2), Mid(strDate, 4, 2)) Then
MSHFlexGrid1.TextMatrix(lngRow, 0) = "BAD DATE FORMAT"
End If
ASKER
Did I miss a Wilder comment about that?No he didn't say one way or the other. He also didn't answer my
Will the date always be 10 characters including two slashes, or could it be just 1/1 or just 23?question.
ASKER
ASKER
ASKER
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.
TRUSTED BY
ASKER
Open in new window