Foxtable(狐表)用户栏目专家坐堂 → 从字符串“”到类型“Double”的转换无效


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

主题:从字符串“”到类型“Double”的转换无效

美女呀,离线,留言给我吧!
mtx
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:114 积分:978 威望:0 精华:0 注册:2017/4/24 21:44:00
从字符串“”到类型“Double”的转换无效  发帖心情 Post By:2019/5/13 11:53:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20190513114829.png
图片点击可在新窗口打开查看
    您好,我的代码如下,但是运算之后会显示字符串从“”到“double”转换无效,不知道是哪里出现问题了,表中的每一列的类型我都检查了一遍,“序号”为整数型,“呼吸机ID”为字符型,“变量1”为字符型,“变量2”为字符型,“同为1”为双精度小数,“比例”为双精度小数。
    另外,运算完成之后,“变量1”、“变量2”列显示的还是数字,按理说显示的应该是文字来着。

Dim i As Integer
Dim j As Integer
图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20190513114358.png
图片点击可在新窗口打开查看
Dim k As Integer
Dim lst1 As WinForm.ListBox = e.Form.Controls("ListBox1")
Dim m As Integer
DataTables("统计表2").DeleteFor("")
For m = 0 To lst1.items.Count- 1    
    Dim huxijiName As String    
    huxijiName = lst1.items(m)  
    Dim sum1(Tables(huxijiName).Cols.Count - 1,Tables(huxijiName).Cols.Count - 1) As Integer    
    For i = 3 To Tables(huxijiName).Cols.Count - 2
        For j = i+1 To Tables(huxijiName).Cols.Count - 1          
            sum1(i,j)=0
            For k = 0 To Tables(huxijiName).Rows.Count - 1                
                If Tables(huxijiName).Rows(k)(i) = 1 And Tables(huxijiName).Rows(k)(j) = 1 Then
                    sum1(i,j) = sum1(i,j)+1                    
                End If               
            Next
        Next
    Next    
    
    Dim aa As Integer
    aa= Tables("统计表2").Rows.Count+1
    
    
    For i = 3 To Tables(huxijiName).Cols.Count - 2
        For j = i+1 To Tables(huxijiName).Cols.Count - 1
            
            'messagebox.show("sum1(" & i & ","& j & ")= " & sum1(i,j))
            
            Tables("统计表2").AddNew
            Tables("统计表2").Current("序号") = aa
            
            Tables("统计表2").Current("呼吸机ID") = huxijiName
            Tables("统计表2").Current("变量1") = i
            Tables("统计表2").Current("变量2") = j
            Tables("统计表2").Current("同为1") = sum1(i,j)
            
                      
            Tables("统计表2").Current("比例") = sum1(i,j)/Tables(huxijiName).Rows.Count
            
            
            aa= aa +1
            
        Next
    Next
    
Next

Dim a1 As String
a1 = "每分呼气量过高"
Dim a2 As String
a2 ="每分呼气量过低"
Dim a3 As String
a3 ="氧浓度过高"
Dim a4 As String
a4 = "氧浓度过低"
Dim a5 As String
a5 ="呼吸暂停"
Dim a6 As String
a6 ="呼吸频率过高"
Dim a7 As String
a7 = "呼吸频率过低"
Dim a8 As String
a8 = "呼气末正压过高"
Dim a9 As String
a9 = "呼气末正压过低"


For i = 0 To Tables("统计表2").Rows.Count - 1
    For j = 0 To Tables("统计表2").cols.Count - 1
        
        If Tables("统计表2").Rows(i)("变量1") = "3" Then
            Tables("统计表2").Rows(i)("变量1") = a1
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "4" Then
            Tables("统计表2").Rows(i)("变量1") = a2
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "5" Then
            Tables("统计表2").Rows(i)("变量1") = a3
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "6" Then
            Tables("统计表2").Rows(i)("变量1") = a4
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "7" Then
            Tables("统计表2").Rows(i)("变量1") = a5
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "8" Then
            Tables("统计表2").Rows(i)("变量1") = a6
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "9" Then
            Tables("统计表2").Rows(i)("变量1") = a7
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "10" Then
            Tables("统计表2").Rows(i)("变量1") = a8
        End If
        
        If Tables("统计表2").Rows(i)("变量1") = "11" Then
            Tables("统计表2").Rows(i)("变量1") = a9
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "3" Then
            Tables("统计表2").Rows(i)("变量2") = a1
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "4" Then
            Tables("统计表2").Rows(i)("变量2") = a2
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "5" Then
            Tables("统计表2").Rows(i)("变量2") = a3
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "6" Then
            Tables("统计表2").Rows(i)("变量2") = a4
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "7" Then
            Tables("统计表2").Rows(i)("变量2") = a5
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "8" Then
            Tables("统计表2").Rows(i)("变量2") = a6
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "9" Then
            Tables("统计表2").Rows(i)("变量2") = a7
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "10" Then
            Tables("统计表2").Rows(i)("变量2") = a8
        End If
        
        If Tables("统计表2").Rows(i)("变量2") = "11" Then
            Tables("统计表2").Rows(i)("变量2") = a9
        End If        
    Next
Next

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/5/13 12:10:00 [只看该作者]

应该是这句代码有错

 

 If Tables(huxijiName).Rows(k)(i) = 1 And Tables(huxijiName).Rows(k)(j) = 1 Then

 

改成

 

 If Tables(huxijiName).Rows(k)(i) = "1" And Tables(huxijiName).Rows(k)(j) = "1" Then


 回到顶部
美女呀,离线,留言给我吧!
mtx
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:114 积分:978 威望:0 精华:0 注册:2017/4/24 21:44:00
  发帖心情 Post By:2019/5/13 20:58:00 [只看该作者]

OK了,谢谢您

 回到顶部