Const row = 10
Const col = 10
Dim state(row, col) As Integer
Dim xgrid As Integer
Dim ygrid As Integer
Private Sub Form_Activate()
xgrid = ScaleWidth / col
ygrid = ScaleHeight / row
For i = 0 To (row - 1)
For j = 0 To (col - 1)
X1 = i * xgrid
Y1 = j * ygrid
X2 = (i + 1) * xgrid
Y2 = (j + 1) * ygrid
Line (X1, Y1)-(X2, Y2), , B
Next j
Next i
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim r As Integer
r = 140
X = X \ xgrid
Y = Y \ ygrid
cx = (X * xgrid + (X + 1) * xgrid) / 2
cy = (Y * ygrid + (Y + 1) * ygrid) / 2
black = RGB(0, 0, 0)
white = RGB(255, 255, 255)
If (Button = 1) Then
If state(X, Y) = 0 Then
Circle (cx, cy), r, black
state(X, Y) = 1
ElseIf state(X, Y) = 1 Then
Circle (cx, cy), r, white
state(X, Y) = 0
End If
End If
If (Button = 2) Then
If state(X, Y) = 0 Then
Line (cx - r, cy - r)-(cx + r, cy + r), black
Line (cx - r, cy + r)-(cx + r, cy - r), black
state(X, Y) = 2
ElseIf state(X, Y) = 2 Then
Line (cx - r, cy - r)-(cx + r, cy + r), white
Line (cx - r, cy + r)-(cx + r, cy - r), white
state(X, Y) = 0
End If
End If
End Sub
|