Foxtable(狐表)用户栏目专家坐堂 → 代码


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

主题:代码

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


加好友 发短信
等级:六尾狐 帖子:1470 积分:8981 威望:0 精华:0 注册:2013/10/24 9:12:00
代码  发帖心情 Post By:2015/4/14 10:15:00 [只看该作者]

isDate(Sheet1(1,0).Value) = true 
如果:sheet1(1,0).value = 2015年3月,上述代码不能成立。

 回到顶部
帅哥哟,离线,有人找我吗?
发财
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1470 积分:8981 威望:0 精华:0 注册:2013/10/24 9:12:00
  发帖心情 Post By:2015/4/14 10:16:00 [只看该作者]

应如何改?

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/4/14 10:22:00 [只看该作者]

Dim str As String ="2015年3月"
If System.Text.RegularExpressions.Regex.IsMatch(str,"^(\d{4})年(\d{1,2})月$") Then
   MessageBox.show("是日期")
Else
   MessageBox.show("不是日期")
End If

 回到顶部
帅哥哟,离线,有人找我吗?
jswjyjf
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2552 积分:20045 威望:0 精华:0 注册:2012/5/19 11:57:00
  发帖心情 Post By:2015/4/14 13:22:00 [只看该作者]

上面的语法 帮助里哪个部分有


 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/4/14 13:34:00 [只看该作者]

不是帮助的知识, 你用就可以了.该知识可以独立买一本10厘米厚的书.   叫做  正则表达式   

 回到顶部
帅哥哟,离线,有人找我吗?
发财
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1470 积分:8981 威望:0 精华:0 注册:2013/10/24 9:12:00
  发帖心情 Post By:2015/4/15 10:17:00 [只看该作者]

For Each file As String In filesys .GetFiles(ProjectPath & "报表1")
    If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then
        Dim Book1 As New XLS.Book(file)
        Dim Sheet1 As XLS.Sheet = Book1.Sheets("分户快报")
        Dim Sheet2 As XLS.Sheet = Book1.Sheets("资产负债表")
        Dim Sheet3 As XLS.Sheet = Book1.Sheets("利润及分配表")
        Dim Sheet4 As XLS.Sheet = Book1.Sheets("费用表")
        Dim Sheet5 As XLS.Sheet = Book1.Sheets("工资月报")
        Dim Sheet6 As XLS.Sheet = Book1.Sheets("附列资料")
        Dim s As String = sheet1(2,1).value
        Dim d1 As Date = sheet1(1,1).value
        Dim d2 As Date = sheet1(1,0).value
        Dim d3 As Date = sheet1(1,0).value
        Dim d4 As Date = sheet1(1,1).value
        Dim d5 As Date = sheet1(1,4).value
        Dim d6 As Date = sheet1(1,9).value
        If s.Substring(0,4) = "编制单位" AndAlso s = sheet2(3,0).value AndAlso s = sheet3(2,0).value AndAlso s = sheet4(2,0).value AndAlso s = sheet5(1,0).value AndAlso s = sheet6(1,0).value Then
            Dim r As Row = Tables("审核").AddNew()
            r("单位") =  FileSys.GetName(file)
            r("报表名") = sheet1.name
        Else
            If isDate(d1) = False OrElse d1.year <> vars("cc").year OrElse d1.month <> vars("cc").month Then
                Dim r As Row = Tables("审核").AddNew()
                r("单位") =  FileSys.GetName(file)
                r("报表名") = sheet1.name
            Else If isDate(d2) = False OrElse d2.year <> vars("cc").year OrElse d2.month <> vars("cc").month Then
                Dim r As Row = Tables("审核").AddNew()
                r("单位") =  FileSys.GetName(file)
                r("报表名") = sheet2.name
            Else If isDate(d3) = False OrElse d3.year <> vars("cc").year OrElse d3.month <> vars("cc").month Then
                Dim r As Row = Tables("审核").AddNew()
                r("单位") =  FileSys.GetName(file)
                r("报表名") = sheet3.name
            Else If isDate(d4) = False OrElse d4.year <> vars("cc").year OrElse d4.month <> vars("cc").month Then
                Dim r As Row = Tables("审核").AddNew()
                r("单位") =  FileSys.GetName(file)
                r("报表名") = sheet4.name
            Else If isDate(d5) = False OrElse d5.year <> vars("cc").year OrElse d5.month <> vars("cc").month Then
                Dim r As Row = Tables("审核").AddNew()
                r("单位") =  FileSys.GetName(file)
                r("报表名") = sheet5.name
            Else If isDate(d6) = False OrElse d6.year <> vars("cc").year OrElse d6.month <> vars("cc").month Then
                Dim r As Row = Tables("审核").AddNew()
                r("单位") =  FileSys.GetName(file)
                r("报表名") = sheet6.name
            End If
        End If
    End If
Next

 回到顶部
帅哥哟,离线,有人找我吗?
发财
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1470 积分:8981 威望:0 精华:0 注册:2013/10/24 9:12:00
  发帖心情 Post By:2015/4/15 10:18:00 [只看该作者]

上述代码应如何修改才可简洁些?

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/4/15 10:28:00 [只看该作者]

判断没办法简洁 到哪里去.

 回到顶部
帅哥哟,离线,有人找我吗?
发财
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1470 积分:8981 威望:0 精华:0 注册:2013/10/24 9:12:00
  发帖心情 Post By:2015/4/15 11:11:00 [只看该作者]

s1 = sheet(1,1).value
If s1.Isstring  Then
为什么不能判断?

 回到顶部
帅哥哟,离线,有人找我吗?
Bin
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/4/15 11:19:00 [只看该作者]

string 不用判断啊.所有类型都可以当字符串使用

直接用就好了.


 回到顶部
总数 36 1 2 3 4 下一页