Maria  Salcedo
Maria Salcedo

Reputation: 23

Visual Basic, End of Statement Expected - array?

I've been having issues trying to fix an "End of Statement Expected" BC30205 Error for this program, it is an Interpolation subroutine of the FCC Curves Calculation Program. I'm trying to convert a function in javascript to VB.NET. I've added the code below.

'------- 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

The exact position that I'm getting this error is;

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

Just in u{k}, as you can see here I haven't worked in VB since a lot... so... Thanks for the help you can send me and sorry for my english.

Upvotes: 2

Views: 619

Answers (1)

Karuntos
Karuntos

Reputation: 61

You cannot add curly braces near the double datatype. Curly braces are used to initialize an array.

If you want to compare an array:

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

Note that an array is a zero-based index means that if you want to assign or read the first object of an array, you should do like this: IntArray(0)

Upvotes: 1

Related Questions