请帮我看下这段VB代码

来源:百度知道 编辑:UC知道 时间:2024/06/22 17:17:49
Private Sub Command1_Click()
Dim i, j As Integer
For i = 0 To Picture1.ScaleWidth - 1
For j = 0 To Picture1.ScaleHeight - 1
If ppixel1(i, j) <> 0 Then

Me.Text1 = i
Me.Text2 = j

End If
Next
Next

End Sub
就是一个全黑的图片上有两个白点,一上一下.我想取到上面的白点的坐标,可是总是循环到下面的白点了,怎么半?
袄 是这样啊,那我想两个点的坐标都得到怎么半呢? 比如我又加个TEXT3和4.

Private Sub Command1_Click()
Dim i, j As Integer
For i = 0 To Picture1.ScaleWidth - 1
For j = 0 To Picture1.ScaleHeight - 1
If pictur1.point(i, j) <> 0 Then

Me.Text1 = i
Me.Text2 = j
exit for
End If
Next
Next

找到第一个后要用exit for 退出循环

Private Sub Command1_Click()
Dim i, j
For i = 0 To Picture1.ScaleWidth - 1
For j = 0 To Picture1.ScaleHeight - 1
If ppixel1(i, j) <> 0 Then
Me.Text1 = i
Me.Text2 = j
exit sub
End If
Next
Next

End Sub