Vb.net id您定义了数据数组,什么是防御?公共数据(20000,20)作为字符串公共股票\u id\u temp(10000)作为字符串公共股票\u id\u count作为整数=0公共当前月(10)作为字符串公共次清除\u数据\u数组()数组。清除(数据,040

Vb.net id您定义了数据数组,什么是防御?公共数据(20000,20)作为字符串公共股票\u id\u temp(10000)作为字符串公共股票\u id\u count作为整数=0公共当前月(10)作为字符串公共次清除\u数据\u数组()数组。清除(数据,040,vb.net,Vb.net,id您定义了数据数组,什么是防御?公共数据(20000,20)作为字符串公共股票\u id\u temp(10000)作为字符串公共股票\u id\u count作为整数=0公共当前月(10)作为字符串公共次清除\u数据\u数组()数组。清除(数据,040000)数组。清除(股票\u id\u temp,0,10000)结束子检查x的值当您得到错误时,它是否>=20000?我应该增加或减少该数字吗?您使用数据(20000,20)定义数据数组,因此第一个元素最多有20000项,如果x大于它,您必须


id您定义了数据数组,什么是防御?公共数据(20000,20)作为字符串公共股票\u id\u temp(10000)作为字符串公共股票\u id\u count作为整数=0公共当前月(10)作为字符串公共次清除\u数据\u数组()数组。清除(数据,040000)数组。清除(股票\u id\u temp,0,10000)结束子检查x的值当您得到错误时,它是否>=20000?我应该增加或减少该数字吗?您使用
数据(20000,20)
定义数据数组,因此第一个元素最多有20000项,如果x大于它,您必须增加数组容量。当你得到错误时检查x的值OK,上面的注释是在我输入的时候出现的<代码>数据是一个公共变量。但是读取了多少数据?这个错误是什么意思?在这一行中“从字符串“Pcs”到类型“Double”的转换无效”=FormatNumber(Cdbl(数据(x,4))*Cdbl(数据(x,13))*Cdbl(数据(x,14)),2)@Neqia:我在上面的代码中看不到那一行。听起来是个新问题。
Public Sub load_stockid_monthly_byUP(ByVal type As Integer, ByVal filter As Integer, ByVal input As String)
    Dim sqlquery As String = ""
    Dim myCommand As New MySqlCommand
    Dim myData As MySqlDataReader
    Dim x As Integer = 0
    Dim where As String = ""
    Dim order As String = ""
    If filter = 1 Then
        where = ""
    ElseIf filter = 2 Then
        where = " AND r.type =" & input
    ElseIf filter = 3 Then
        where = " AND s.cat_id =" & input
    ElseIf filter = 4 Then
        where = " AND (s.desp like '% " & input & " %' OR s.desp like '" & input & " %' OR s.desp like '% " & input & "' OR s.desp = '" & input & "')"
    ElseIf filter = 5 Then
        where = " AND (s.cat_id = 1 OR s.cat_id = 2 OR s.cat_id = 4 OR s.cat_id = 5 )"
    ElseIf filter = 6 Then
        where = " AND (s.pallet_id <> 0 OR s.carton_id <> 0)"
        order = " ORDER BY  carton_id, pallet_id , stock_id"
    ElseIf filter = 7 Then
        where = " AND (s.pallet_id <> 0)"
        order = " ORDER BY pallet_id , stock_id"
    ElseIf filter = 8 Then
        where = " AND (s.carton_id <> 0)"
        order = " ORDER BY carton_id, stock_id"
    ElseIf filter = 9 Then
        where = " AND (s.uniform_id <> 0)"
        order = " ORDER BY uniform_id"
    End If


    If type = 1 Then
        sqlquery = "(SELECT s.id AS id,s.stock_id AS stock_id ,s.packing_id AS packing_id ,s.carton_id AS carton_id, s.pallet_id AS pallet_id, s.desp AS desp,i.unit_price AS unit_price, i.rate AS rate, c.type AS cat, u.unit AS uom, s.currency AS currency, s.uniform_id As uniform_id  FROM incoming AS i LEFT JOIN stock AS s ON i.stock_id = s.id LEFT JOIN uom AS u ON s.uom = u.id LEFT JOIN stock_cat AS c ON s.cat_id = c.id LEFT JOIN supplier AS r ON s.supplier_id = r.id WHERE s.active = 1 AND (i.active = 1 OR i.active = 2)" & where & " GROUP BY c.type, s.stock_id , i.unit_price, i.rate ) UNION " _
                    & "(SELECT s.id AS id,s.stock_id AS stock_id ,s.packing_id AS packing_id ,s.carton_id AS carton_id, s.pallet_id AS pallet_id,s.desp AS desp,i.unit_price AS unit_price, i.rate AS rate, c.type AS cat, u.unit AS uom, s.currency AS currency, s.uniform_id As uniform_id  FROM adjust AS i LEFT JOIN stock AS s ON i.stock_id = s.id LEFT JOIN uom AS u ON s.uom = u.id LEFT JOIN stock_cat AS c ON s.cat_id = c.id LEFT JOIN supplier AS r ON s.supplier_id = r.id WHERE s.active = 1 AND i.adjust_qty > 0 AND (i.active = 1 OR i.active = 2)" & where & " GROUP BY c.type, s.stock_id , i.unit_price, i.rate ) " & order
        ' sqlquery = "SELECT s.id AS id,s.stock_id AS stock_id ,s.desp AS desp,i.unit_price AS unit_price, i.rate AS rate, c.type AS cat, u.unit AS uom, s.currency AS currency FROM incoming AS i LEFT JOIN stock AS s ON i.stock_id = s.id LEFT JOIN uom AS u ON s.uom = u.id LEFT JOIN stock_cat AS c ON s.cat_id = c.id LEFT JOIN supplier AS r ON s.supplier_id = r.id WHERE (i.active = 1 OR i.active = 2)" & where & " GROUP BY c.type, s.stock_id , i.unit_price ORDER BY c.type ,s.stock_id "
    ElseIf type = 2 Then
        sqlquery = "SELECT s.id AS id,s.stock_id AS stock_id ,s.desp AS desp,n.unit_price AS unit_price, n.rate AS rate, c.type AS cat, u.unit AS uom, s.currency AS currency FROM issue AS i LEFT JOIN stock AS s ON i.stock_id = s.id  LEFT JOIN uom AS u ON s.uom = u.id LEFT JOIN incoming AS n ON i.irm_id = n.id LEFT JOIN stock_cat AS c ON s.cat_id = c.id LEFT JOIN supplier AS r ON s.supplier_id = r.id WHERE s.active = 1 AND i.active = 1" & where & " GROUP BY c.type, s.stock_id , n.unit_price ORDER BY c.type ,s.stock_id"
    End If


    stock_id_count = 0
    ConnectmyDB()
    myCommand.Connection = conn

    myCommand.CommandText = sqlquery
    myData = myCommand.ExecuteReader

    If myData.HasRows = False Then
        x = 1
    Else
        While myData.Read
            data(x, 0) = myData.GetInt32("id")
            data(x, 1) = myData.GetString("stock_id")
            data(x, 2) = myData.GetString("desp")
            data(x, 8) = myData.GetString("unit_price")

            data(x, 9) = myData.GetString ("rate")

            data(x, 12) = myData.GetString("cat")
            data(x, 14) = myData.GetString("uom")
            data(x, 16) = myData.GetString("packing_id")
            x = x + 1
        End While
    End If
    DisconnectDatabase()
    stock_id_count = x

End Sub 'closing stock unit price