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) Dim za_row0 = {0, 0} Dim zb_row0 = {0, 0, 0, 0, 0} Dim zab_row0 = {0, 0, 0} Dim zx_row0 = {0, 0, 0, 0} Dim zy_row0 = {0, 0, 0, 0} Dim zxy_row0 = {0, 0, 0, 0} Dim x3, x4, a3, y3, y4, b3, z33, z43, z34, z44, x2, a2, z23, z24, x5, a4, z53, z54 As Double 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 Dim zx3b3, zx4b3, zy3a3, zy4a3, a, b, c, d, e, a3sq, b3sq, p02, p03, p12, p13, p20, p21, p22 As Double Dim p23, p30, p31, p32, p33, dy, q0, q1, q2, q3, dx As Double ‘———— lx = Math.Floor(lx) lxm1 = Math.Floor(lx – 1) For k = 0 To n Step -1 If u{k} >= x{lxm1} Then 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 |
注意数组是从零开始的索引意味着如果你想分配或读取数组的第一个对象,你应该这样做:
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/267507.html