早教吧 育儿知识 作业答案 考试题库 百科 知识分享

关于vb下标越界的处理方法求高手指点哪个好人受累给看看FunctionCHQXf(X)Dimi,jDimb,hAsVariantb=Array(1.4,1.41,1.42,1.43,1.44,1.45,1.46,1.47,1.48,1.49,1.5,1.51,1.52,1.53,1.54,1.55,1.56,1.57,1

题目详情
关于vb下标越界的处理方法 求高手指点 哪个好人受累给看看
Function CHQXf(X)
Dim i, j
Dim b, h As Variant
b = Array(1.4, 1.41, 1.42, 1.43, 1.44, 1.45, 1.46, 1.47, 1.48, 1.49, 1.5, 1.51, 1.52, 1.53, 1.54, 1.55, 1.56, 1.57, 1.58, 1.59, 1.6, 1.61, 1.62, 1.63, 1.64, 1.65, 1.66, 1.67, 1.68, 1.69)
h = Array(12.6, 13.1, 13.6, 14.2, 14.8, 15.5, 16.3, 17.1, 18.1, 19.1, 20.1, 21.2, 22.4, 23.7, 25, 26.7, 28.5, 30.4, 32.6, 35.1, 37.8, 40.7, 43.7, 46.8, 50, 53.4, 56.8, 60.4, 64, 67.8)

If X < b(1) Then
i = 0
CHQXf = h(i) + (X - b(i)) * (h(i + 1) - h(i)) / (b(i + 1) - b(i))
ElseIf X >= b(29) Then
i = 29
1 CHQXf = h(i) + (X - b(i)) * (h(i + 1) - h(i)) / (b(i + 1) - b(i))
Else
For j = 1 To 28
If X >= b(j) And X < b(j + 1) Then
i = j
CHQXf = h(i) + (X - b(i)) * (h(i + 1) - h(i)) / (b(i + 1) - b(i))
Exit For
End If
Next j
End If
End Function
▼优质解答
答案和解析
你的b、h的下标范围是0到29,不是1-30