关于 java:Visual Basic,预期语句结束 – 数组?

Visual Basic, End of Statement Expected – array?

我在尝试修复此程序的”预期语句结束”BC30205 错误时遇到问题,它是 FCC 曲线计算程序的插值子程序。我正在尝试将 javascript 中的函数转换为 VB.NET。我在下面添加了代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
‘——- 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

我得到这个错误的确切位置是;

1
2
3
4
 If u{k} >= x{lxm1} Then
                ix = lx
            ElseIf u{k} < x{0} Then
                ix = 0

就在 u{k} 中,如您在此处所见
我已经很久没有在 VB 中工作了…所以…感谢您发送给我的帮助,并为我的英语感到抱歉。


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

如果要比较一个数组:

1
2
3
4
5
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)


原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/267507.html

(0)
上一篇 2022年6月18日
下一篇 2022年6月18日

相关推荐

发表回复

登录后才能评论