以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]将小写中文格式转换为日期格式  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=115632)

--  作者:天一生水
--  发布时间:2018/3/10 18:55:00
--  [求助]将小写中文格式转换为日期格式
      

说明里有CLDate将日期转换为小写中文格式:

 

Dim DateStr As String
DateStr = CLDate(#12/31/2008#)
Output.Show(DateStr)

上述代码的输出为:二○○八年十二月三十一日

 

能否反过来将 二〇一七年六月二十二日  转换成日期格式:2017-06-22


--  作者:有点甜
--  发布时间:2018/3/11 21:23:00
--  

参考代码

 

Dim str As String = "二〇一七年六月二十二日"
Dim s As String = "〇一二三四五六七八九"

Dim ns As String = ""
For i As Integer = 0 To str.length-1
    If str(i) = "年" OrElse str(i)= "月" Then
        ns &= "-"
    ElseIf str(i) = "日" Then
        \'不操作
    ElseIf str(i) = "十" Then
        If str(i-1) = "年" OrElse str(i-1) = "月" Then
            ns &= "1"
        End If
    Else
        Dim idx As Integer = s.IndexOf(str(i))
        If idx >= 0 Then
            ns &= idx
        End If
    End If
Next

msgbox(ns)