以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  求助:从字符串“10mm”到类型“Double”的转换无效。  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=92595)

--  作者:ww7686
--  发布时间:2016/11/8 0:18:00
--  求助:从字符串“10mm”到类型“Double”的转换无效。

求助:从字符串“10mm”到类型“Double”的转换无效。
输入字符串的格式不正确。
请问各位大侠是什么地方出错!

多谢

 

 

 

Select Case e.DataCol.Name
    Case "规格型号"
        Dim ft As String  = e.DataRow("规格型号")
        Dim nian As String = Forms("核算管理").Controls("ComboBox1").value
        Dim yue As String = Forms("核算管理").Controls("ComboBox2").value
        Dim bumen As String = Forms("核算管理").Controls("ComboBox3").value
        e.DataRow("核算日期") = nian + "年" + yue + "月"
        e.DataRow("施工班组") = bumen
\'给物料基础信息赋值

        Dim wwww As DataRow = DataTables("材料信息登记").Find("规格型号 = \'" & ft & "\'")
        e.DataRow("材料名称") = wwww("材料名称")
        e.DataRow("单位") = wwww("单位")
        e.DataRow("单价") = wwww("单价")
 \'给上月结存赋值

        Dim y As Integer
        Dim m As Integer
        If yue = 1 Then
          y = CInt(nian) - 1
          m = 12
        Else
          y = CInt(nian)
          m = CInt(yue) - 1
        End If
        Dim FirstDay As Date = New Date(y,m,1) \'第一天
        Dim LastDay As Date = New Date(y,m,Date.DaysInMonth(y,m))
        e.DataRow("上月结存") = DataTables("物资库存").Compute("Sum(数量)","规格型号 = \'" & ft & "\' and 用料单位 = \'" & bumen & "\' and [日期] >= #" & FirstDay & "# and [日期] <= #" & LastDay & "#")
        If e.DataRow("上月结存") = Nothing Then
        e.DataRow("上月结存") = 0
        End If
\'给本期领用赋值

        Dim q As Integer = CInt(nian)
        Dim w As Integer = CInt(yue)
        Dim a1 As Date = New Date(q,w,1) \'第一天
        Dim a2 As Date = New Date(q,w,Date.DaysInMonth(q,w))
        e.DataRow("实耗数量") = DataTables("物资发料单").Compute("Sum(数量)","规格型号 = \'" & ft & "\' and 用料单位 = \'" & bumen & "\' and [日期] >= #" & a1 & "# and [日期] <= #" & a2 & "#")
        If e.DataRow("实耗数量") = Nothing Then
        e.DataRow("实耗数量") = 0
        End If
\'给期末存量赋值

        e.DataRow("期末存量") = DataTables("结存表").Compute("Sum(结存数量)","物料编号 = \'" & ft & "\' and 部门描述 = \'" & bumen & "\' and [日期] >= #" & a1 & "# and [日期] <= #" & a2 & "#")
        If e.DataRow("期末存量") = Nothing Then
        e.DataRow("期末存量") = 0
        End If
End Select

DataTables("物资消耗核算表").Save()


--  作者:有点色
--  发布时间:2016/11/8 9:05:00
--  

1、调试技巧

 

http://www.foxtable.com/webhelp/scr/1485.htm

 

2、如果要给数值列赋值,这样写

 

Dim str As String = "10mm"

msgbox(val(str))