首页 > 文化

运行时错误9下标越界

更新时间2018-03-14 14:51:01

Function GetCellTextLine(i As Integer, j As Integer, Line As Integer)
Dim S$, V
S = Cells(i, j).Text
V = Split(S, Chr(10))
GetCellTextLine = V(Line - 1)
接下来调用 T = GetCellTextLine(i, j, 1) & GetCellTextLine(i, j, 2) & GetCellTextLine(i, j, 3) 却是下标越界 什么原因啊可能是单元格的文本没有那么多行,超过了。
修改为,如果调用时的参数Line超过了单元格的文本行数,则返回空的字符串。
Function GetCellTextLine(i As Integer, j As Integer, Line As Integer)
Dim S$, V
S = Cells(i, j).Text
V = Split(S, Chr(10))
If Line > UBound(V) + 1 Then
GetCellTextLine = ""
Else
GetCellTextLine = V(Line - 1)
End If
End Function

相关标签:越界

上一篇:运行时错误9下标越界

下一篇:越界采矿违反了《中华人民共和国矿产资源法》哪一条