vb 标签未定义 图片处理

来源:百度知道 编辑:UC知道 时间:2024/07/07 23:45:06
rivate Sub Command1_Click()
Picture1.AutoSize = True
Picture1.ScaleMode = 3
Picture1.Picture = LoadPicture("c:/3.bmp")
End Sub

Private Sub Command2_Click()
Dim i As Long
Dim j As Long
Dim l As Long
Dim o As Long
Dim m As Long
l = j - 1

For j = 1 To 89
For i = 1 To 89
If Picture1.Point(i, j) < 16777215 And Picture1.Point(i, l) = 16777215 Then o = j Else
If Picture1.Point(i, j) < 16777215 And Picture1.Point(i, l) < 16777215 Then GoTo 15 Else
: If Picture1.Point(i, j) = 16777215 And Picture1.Point(i, l) < 16777215 Then m = l Else
: Next i
Print o
Print m
Next j
End Sub

错误:标签未定义
图片是只有黑色和白色的图片
16777215 代表白色 等于是白色 小于是黑色
请问错在哪儿?
goto 15 可以替换 next j 吗?(那里的15是For j = 1 To 89 语句,这可能错,但不是主要错误)

如果你要跳到 next j ,先要定义标签,标签的末尾是英文冒号(例如,ccc:),跳到 ccc 所在语句这样写 goto ccc
另外,你的两个 else 属多余,因为后面没有任何语句。
句首两个:也属多余,如果英文冒号在句尾,表示标签,否则表示将多行语句写在一行,例如
a = 1
b = 2
c = 3
可以写成
a = 1: b = 2: c = 3

修改后的代码如下
For j = 1 To 89
For i = 1 To 89
If Picture1.Point(i, j) < 16777215 And Picture1.Point(i, l) = 16777215 Then o = j
If Picture1.Point(i, j) < 16777215 And Picture1.Point(i, l) < 16777215 Then GoTo ccc
If Picture1.Point(i, j) = 16777215 And Picture1.Point(i, l) < 16777215 Then m = l
Next i
Print o
Print m
ccc:
Next j