Foxtable(狐表)用户栏目专家坐堂 → 一个小练习:数字转换为日期


  共有3636人关注过本帖树形打印复制链接

主题:一个小练习:数字转换为日期

帅哥哟,离线,有人找我吗?
czy
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章 三级勋章 二级勋章
等级:超级版主 帖子:6318 积分:33963 威望:0 精华:10 注册:2008/8/31 20:56:00
  发帖心情 Post By:2014/10/18 13:12:00 [显示全部帖子]

应该加上捕获异常错误代码,否则会报错的。

 

If e.DataCol.Name = "数字" Then
    try
        If e.DataRow("数字") Like "########"
            e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"yyyyMMdd",Nothing)
        Else If e.DataRow("数字") Like "######"
            e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"yyMMdd",Nothing)
        Else If e.DataRow("数字") Like "##[-]##[-]##"
            e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"yy-MM-dd",Nothing)
        Else If e.DataRow("数字") Like "##[-]##"
            e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"MM-dd",Nothing)
        Else If e.DataRow("数字") Like "####"
            e.DataRow("日期") = DateTime.ParseExact(e.DataRow("数字"),"MMdd",Nothing)
        Else
            Return
        End If
    Catch ex As Exception
    End try
End If

 

 


 回到顶部