以文本方式查看主题

-  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=73471)

--  作者:hbhb
--  发布时间:2015/8/19 23:55:00
--  日本鬼子怎么来了?
大师:这是什么鬼?
导入excel表后      姓名、工资、   职务    执行下面的代码正确
                        王五   1000    经理

但把工资删除后导入,  姓名、           职务     执行下面的代码就出错,是什么原因?
                              王五   1000    经理




执行下面的代码

Dim maxcol As Integer = 100
Dim b1 As Table
Dim d As WinForm.Table = Forms("frmZcfzbList").Controls("Table2")
b1 = d.Table

For Each r1 As Row In b1.Rows
    For Each l1 As Col In b1.Cols
        If l1.Index > = maxcol Then
            Exit For
        Else
          If r1.IsNull(l1.name) = False  Then
            r1(l1.name) = trim(r1(l1.name).replace(" ",""))
          End If
        End If
    Next
Next








--  作者:大红袍
--  发布时间:2015/8/20 0:15:00
--  
转成字符串
 
Dim maxcol As Integer = 100
Dim b1 As Table
Dim d As WinForm.Table = Forms("frmZcfzbList").Controls("Table2")
b1 = d.Table

For Each r1 As Row In b1.Rows
    For Each l1 As Col In b1.Cols
        If l1.Index > = maxcol Then
            Exit For
        Else
          If r1.IsNull(l1.name) = False  Then
            r1(l1.name) = Cstr(r1(l1.name)).replace(" ","")
          End If
        End If
    Next
Next

--  作者:hbhb
--  发布时间:2015/8/20 0:23:00
--  
谢谢!数字不是字符吗? 那如果是整数列,122  067.87,我要把数据规范去除数字的空格,难道也要转来转去?
--  作者:hbhb
--  发布时间:2015/8/20 0:29:00
--  
不行,未找到double的公共成员replace?
--  作者:hbhb
--  发布时间:2015/8/20 1:04:00
--  
excel导入后后默认列的类型,且该列的find查找字符代码也不好用?怪事?
--  作者:大红袍
--  发布时间:2015/8/20 9:24:00
--  

2楼代码没有问题。

 

出错,就做例子上来测试。


--  作者:hbhb
--  发布时间:2015/8/20 9:43:00
--  
原因找到了,是其他代码的问题,,模糊查找时,没有判断列类型。excel导入时他是根据什么定义列类型的?帮助中的哪里?
--  作者:大红袍
--  发布时间:2015/8/20 9:51:00
--  
以下是引用hbhb在2015/8/20 9:43:00的发言:
原因找到了,是其他代码的问题,,模糊查找时,没有判断列类型。excel导入时他是根据什么定义列类型的?帮助中的哪里?

 

判断变量的类型?

 

Dim str = "12345"
If Typeof str Is Double Then
   
Else If Typeof str Is String Then
    msgbox("string")
End If


--  作者:hbhb
--  发布时间:2015/8/20 10:25:00
--  
没有看到,在帮助中搜“typeof”  哪里的有?
--  作者:大红袍
--  发布时间:2015/8/20 11:15:00
--  

帮助里面没有的,你就百度一下吧

 

http://www.baidu.com/baidu?wd=c%23+typeof&tn=monline_4_dg