Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:代码取值有点问题,帮忙看下

1楼
lsfdf 发表于:2012/2/2 10:19:00

当月份大于9的时候是正常的,小于的时候应该是2013-07这样的,结果是2013-7-,帮忙看下,谢谢!

If e.DataCol.Name = "有效期" Then
    Dim dt As DataRow = e.DataRow
    If dt.IsNull("有效期") Then
        dt("有效期至") = Nothing
    Else
        Dim t As String=  dt("有效期")
       t= mid(t,1,4) & "-" & Mid(t,6,2)
        dt("有效期至") = t
            End If
End If


此主题相关图片如下:未命名2.jpg
按此在新窗口浏览图片
2楼
狐狸爸爸 发表于:2012/2/2 10:35:00
If e.DataCol.Name = "有效期" Then
    Dim dt As DataRow = e.DataRow
    If dt.IsNull("有效期") Then
        dt("有效期至") = Nothing
    Else
        Dim t As Date=  dt("有效期")
        t= t.Year & "-" & t.Month
        dt("有效期至") = t
    End If
End If
3楼
lsfdf 发表于:2012/2/2 11:10:00

谢谢思路,变通了下,不然要报错

If e.DataCol.Name = "有效期" Then
    Dim dt As DataRow = e.DataRow
    If dt.IsNull("有效期") Then
        dt("有效期至") = Nothing
    Else
        Dim t As Date=  dt("有效期")

      dim t1 as string
        t1= t.Year & "-" & t.Month
        dt("有效期至") = t1
    End If
End If

 

比原来的好些了,取出来是:2012-4

 

我还是格式成2012-04 这样的,该如何操作呢


共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01953 s, 2 queries.