Completely convert date time to Chinese characters

zhaozj2021-02-16  92

The following code can convert any date (1000-01-01-0: 0: 0 ------> 9999-12-31 23:59:59) to Chinese characters

Function Datename (Byval mydate as string) AS STRING

DIM I as Long, MyStr (6) AS String, Temp as stringconst all as string = "○ one or two three four five six eighty ninety"

If not isdate (mydate) THEN 'error handles MSGBox "non-correct date format!", Vbinformation, "warning" exit functionend ifmydate = cdate (mydate)' Date format conversion for i = 0 to 6Mystr (i) = choose (i 1, Year (MyDate), MONTHNAME (Month (MyDate), Hour (MyDate), Minute (MyDate, WeekdayName (Weekday (MyDate, vbsunday)) Nextfor i = 1 To 4 'Generated Year Temp = Temp & Mid (All, CINT (MID (MISTR (0), I, 1)) 1, 1)' Trans Year To Chinese CharacternexTMystr (0) = Temp & "Year" Temp = Choose Val (MySTR (2)) / 10 1, "" "," Ten "," Twenty "," Thirty ") & Trim (MID (All, Val (MyStr (2)) MOD 10 1, 1) ) & "Japan" generating day mystr (2) = replace (Temp, "1010", "10th") 'Avoid "30" Temp = Choose (Val (mYStr (3)) / 10 1, "" "" Ten "," Twenty ") & Trim (MID (All, Val (MyStr (3)) MOD 10 1, 1)) &" Time "" MYSTR (3) = Replace (TEMP, "10 时", "10") Temp = Choose (Val (MyStr (4)) / 10 1, "" "" 10 "," Twenty "," Thirty "," Forty "," 50 ") & Trim (MID (All, Val (MyStr (4)) MOD 10 1, 1)) &" Division "'Biomei MyStr (4) = Replace (Temp," 10 ○ " "Very") Temp = Choose (Val (MyStr (5)) / 10 1, "" "," Ten "," Twenty "," Thirty "," Forty "," Five ") & Trim (MID (All, Val MYSTR (5)) MOD 10 1, 1) & "Second" 'Generate Seconds Mystr (5) = Replace (Temp, "10 ○", "Ten Second") Datename = Join (MyStr, "") END FunctionPrivate Sub Command1_Click () msgbox datename (now) End Sub

转载请注明原文地址:https://www.9cbs.com/read-14541.html

New Post(0)