图像压缩中的下标越界问题
Private Sub command4_Click()
Dim h, w As Integer
Dim x, y, bi, wi As Long
Dim cl As Long
Dim m(10000) As Long
Dim k As Long
Dim r, g, b, n As Integer
Dim fName As String
fName = App.Path & "\Compact.txt"
tem = Picture1.Point(0, 0)
n = 0
j = 0
Open fName For Output As #1
h = Picture1.ScaleHeight
w = Picture1.ScaleWidth
For y = 0 To h - 1
For x = 0 To w - 1
i = Picture1.Point(y, x)
If i = tem Then
j = j + 1
Else
'Print #1, str(tem); str(j)
tem = i
j = 1
End If
n = n + 2
m(n - 2) = str(i)
m(n - 1) = str(j)
Print #1, m(n - 2); m(n - 1)
Next x
Next y
Close #1
End Sub
红色标注的地方运行时下标越界,可我怎么也查不出为什么?我的n-1最小也就1,没越界呀