Visual Basic,语句结束预期 - 数组?

时间:2017-07-04 13:24:27

标签: java .net vb.net compiler-errors

我一直在尝试修复预期的#34;声明结束" BC30205该程序出错,它是FCC Curves Calculation Program的插值子程序。我试图将javascript中的函数转换为VB.NET。我已添加以下代码。

'------- ITPLBV --------------------------------------------------------------------------------------------------
        'Interpolation subroutine
        'Arguments:
        'lx  Number of columns in table.
        'ly  Number of rows in table.
        'x   Column enumeration values.
        'y   Row enumeration values.
        'z   Data table.
        'n   Number of points to lookup.
        'u   Column values for lookup points.
        'v   Row values for lookup points.
        'w   Return result of lookups.

Private Sub Itplbv(lx As Double, ly As Double, x As Double, y As Double, z As Double, n As Double, u As Double, v As Double, w As Double)
    'declarations and initializations
    Dim lxm1, lxp1, lym1, lyp1, ixpv, iypv, k, ix, iy, imn, imx, jx, jy, jx1, jy1 As Double
    lxm1 = lxp1 = lym1 = lyp1 = ixpv = iypv = k = ix = iy = imn = imx = jx = jy = jx1 = jy1 = 0

    Dim za_row0 = {0, 0}
    Dim za_row1 = {0, 0}
    Dim za_row2 = {0, 0}
    Dim za_row3 = {0, 0}
    Dim za_row4 = {0, 0}
    Dim za = {za_row0, za_row1, za_row2, za_row3, za_row4}   'za[5, 2]

    Dim zb_row0 = {0, 0, 0, 0, 0}
    Dim zb_row1 = {0, 0, 0, 0, 0}
    Dim zb = {zb_row0, zb_row1}                              'zb[2, 5]

    Dim zab_row0 = {0, 0, 0}
    Dim zab_row1 = {0, 0, 0}
    Dim zab_row2 = {0, 0, 0}
    Dim zab = {zab_row0, zab_row1, zab_row2}                  'zab[3, 3]

    Dim zx_row0 = {0, 0, 0, 0}
    Dim zx_row1 = {0, 0, 0, 0}
    Dim zx_row2 = {0, 0, 0, 0}
    Dim zx_row3 = {0, 0, 0, 0}
    Dim zx = {zx_row0, zx_row1, zx_row2, zx_row3}             'zx[4, 4]

    Dim zy_row0 = {0, 0, 0, 0}
    Dim zy_row1 = {0, 0, 0, 0}
    Dim zy_row2 = {0, 0, 0, 0}
    Dim zy_row3 = {0, 0, 0, 0}
    Dim zy = {zy_row0, zy_row1, zy_row2, zy_row3}             'zy[4, 4]  

    Dim zxy_row0 = {0, 0, 0, 0}
    Dim zxy_row1 = {0, 0, 0, 0}
    Dim zxy_row2 = {0, 0, 0, 0}
    Dim zxy_row3 = {0, 0, 0, 0}
    Dim zxy = {zxy_row0, zxy_row1, zxy_row2, zxy_row3}         'zxy[4, 4] 

    Dim x3, x4, a3, y3, y4, b3, z33, z43, z34, z44, x2, a2, z23, z24, x5, a4, z53, z54 As Double
    x3 = x4 = a3 = y3 = y4 = b3 = z33 = z43 = z34 = z44 = x2 = a2 = z23 = z24 = x5 = a4 = z53 = z54 = 0.0

    Dim a1, a5, y2, b2, z32, z42, y5, b4, z35, z45, b1, b5, w2, w3, sw, wx2, wx3, wy2, wy3, w1, w4, w5 As Double
    a1 = a5 = y2 = b2 = z32 = z42 = y5 = b4 = z35 = z45 = b1 = b5 = w2 = w3 = sw = wx2 = wx3 = wy2 = wy3 = w1 = w4 = w5 = 0.0

    Dim zx3b3, zx4b3, zy3a3, zy4a3, a, b, c, d, e, a3sq, b3sq, p02, p03, p12, p13, p20, p21, p22 As Double
    zx3b3 = zx4b3 = zy3a3 = zy4a3 = a = b = c = d = e = a3sq = b3sq = p02 = p03 = p12 = p13 = p20 = p21 = p22 = 0.0

    Dim p23, p30, p31, p32, p33, dy, q0, q1, q2, q3, dx As Double
    p23 = p30 = p31 = p32 = p33 = dy = q0 = q1 = q2 = q3 = dx = 0.0

    '------------
    'Calculations begin

    lx = Math.Floor(lx)
    ly = Math.Floor(ly)

    lxm1 = Math.Floor(lx - 1)
    lxp1 = Math.Floor(lx + 1)
    lym1 = Math.Floor(ly - 1)
    lyp1 = Math.Floor(ly + 1)
    ixpv = -1
    iypv = -1

    For k = 0 To n Step -1

        If u{k} >= x{lxm1} Then
            ix = lx
        ElseIf u{k} < x{0} Then
            ix = 0
        Else
            imn = 1
            imx = lxm1
            Do
                ix = Math.Floor((imn + imx) / 2)
                If u{k} >= x{ix} Then
                    imn = ix + 1
                Else
                    imx = ix
                End If
            Loop While (imx > imn)
            ix = imx
        End If
        ix = Math.Floor(ix)

    Next k

End Sub

我收到此错误的确切位置是;

 If u{k} >= x{lxm1} Then
                ix = lx
            ElseIf u{k} < x{0} Then
                ix = 0

就在你{k},你可以看到here 我从未在VB工作过很多......所以...感谢您的帮助,您可以发送给我并抱歉我的英语。

1 个答案:

答案 0 :(得分:1)

您不能在double数据类型附近添加花括号。大括号用于初始化数组。

如果你想比较一个数组:

Dim IntArray As Integer = {2, 0} 'This array has 2 value, 2 and 0.
'Compare it
If IntArray(1) >= 7 Then 'You can only compare with one value in an array
    Console.WriteLine("It is more than 7!")
End If

请注意,数组是从零开始的索引意味着如果要分配或读取数组的第一个对象,则应该这样做:IntArray(0)