主题:请求帮忙:日期小写转换成大写
我写了段日期小写转换成大写的程序,但发现如果是“10”日的话,转换成大写就成了“十O”,而如果是“20”或者“30”则不会有这情况,请各位老大给指点修改一下。
Public Function DateToUpper(ByVal DateStr As String) As String
Dim DateStrLength, D_Flags As Integer '定义日期字符串长度 变量
Dim DStrSp(2) As String
Try
DateStr = CDate(DateStr).ToLongDateString
DateStr = DateStr.Replace("0", "○")
DateStr = DateStr.Replace("1", "一")
DateStr = DateStr.Replace("2", "二")
DateStr = DateStr.Replace("3", "三")
DateStr = DateStr.Replace("4", "四")
DateStr = DateStr.Replace("5", "五")
DateStr = DateStr.Replace("6", "六")
DateStr = DateStr.Replace("7", "七")
DateStr = DateStr.Replace("8", "八")
DateStr = DateStr.Replace("9", "九")
DateStrLength = DateStr.Length
If DateStrLength > 9 Then '当 天数 or 月数 大于9时
If DateStrLength = 10 Then D_Flags = 8 Else D_Flags = 9
DStrSp = DateStr.Split("月")
If DStrSp(0).Length >= 7 Then
Mid(DateStr, 6, 1) = "十"
If Mid(DateStr, 7, 1) = "○" Then DateStr = DateStr.Remove(6, 1) : D_Flags = D_Flags - 1
End If
If DStrSp(1).Length = 3 Then
If Mid(DStrSp(1), 1, 1) = "一" Then Mid(DateStr, D_Flags, 1) = "十" Else DateStr = DateStr.Insert(D_Flags, "十")
If Mid(DateStr, D_Flags + 2, 1) = "○" Then DateStr = DateStr.Remove(D_Flags + 1, 1)
End If
End If
Return DateStr
Catch ex As Exception
Return "Err DateString"
End Try
End Function
Public Function DateToUpper(ByVal DateStr As String) As String
Dim DateStrLength, D_Flags As Integer '定义日期字符串长度 变量
Dim DStrSp(2) As String
Try
DateStr = CDate(DateStr).ToLongDateString
DateStr = DateStr.Replace("0", "○")
DateStr = DateStr.Replace("1", "一")
DateStr = DateStr.Replace("2", "二")
DateStr = DateStr.Replace("3", "三")
DateStr = DateStr.Replace("4", "四")
DateStr = DateStr.Replace("5", "五")
DateStr = DateStr.Replace("6", "六")
DateStr = DateStr.Replace("7", "七")
DateStr = DateStr.Replace("8", "八")
DateStr = DateStr.Replace("9", "九")
DateStrLength = DateStr.Length
If DateStrLength > 9 Then '当 天数 or 月数 大于9时
If DateStrLength = 10 Then D_Flags = 8 Else D_Flags = 9
DStrSp = DateStr.Split("月")
If DStrSp(0).Length >= 7 Then
Mid(DateStr, 6, 1) = "十"
If Mid(DateStr, 7, 1) = "○" Then DateStr = DateStr.Remove(6, 1) : D_Flags = D_Flags - 1
End If
If DStrSp(1).Length = 3 Then
If Mid(DStrSp(1), 1, 1) = "一" Then Mid(DateStr, D_Flags, 1) = "十" Else DateStr = DateStr.Insert(D_Flags, "十")
If Mid(DateStr, D_Flags + 2, 1) = "○" Then DateStr = DateStr.Remove(D_Flags + 1, 1)
End If
End If
Return DateStr
Catch ex As Exception
Return "Err DateString"
End Try
End Function