dear sir,

I made a code in VB6 and it's work fine to draw multiple square in selected area.

The form contain a picture box use for draw my idea.

the form name is "tasfrms"

The picture box is "vieform"

What I need is to caculate the free space which not been used for drawing, and draw a Ellipse inside each sqaure.

The free space will also include the (square space-circle space)

Global C As Double

Global v1 As Double

Global v2 As Double

Global X As Double

Global Y As Double

Global a As Double

Global b As Double

Global d As Double

'xa is the x of filled square

'ya is the y of filled square

'ha is the hieght of the space(picture)

'wa is the width of the space (picture)

's is flag used to change the arrange of filling the total space to try used maximum space as can

Sub COMPUTE_TOTAL44(xa As Double, ya As Double, ha As Double, wa As Double, s As Integer)

On Error GoTo Checks

'If IsNull(tasfrms.Text13.Text

) = False And za <> "0" Then

tasfrms.vieform.Cls

tasfrms.vieform.Line (0, 0)-(wa + 3, ha + 3), QBColor(12), BF

tasfrms.vieform.Line (0, 0)-(wa, ha), QBColor(3), BF

a = xa

b = ya

Y = 0

C = 0

Y1 = b

Do While Y1 <= ha

X = 0

X1 = a

Do While X1 <= wa

Call SHOWBOX(X, Y, X1, Y1)

X = X1

X1 = X1 + a

C = C + 1

Loop

Y = Y1

Y1 = Y1 + b

Loop

If s = 0 Then

v1 = X

C = C + COMPUTE_TOTAL15(ya, xa, ha, wa, v1, X, 0)

Else

v2 = Y

C = C + COMPUTE_TOTAL211(ya, xa, ha, wa, v2, 0, Y)

End If

' Call SHOWBOX(X, Y, X1, Y1)

' tasfrms.vieform.Text1.Text = C

tasfrms.Text3.Text = C

'tasfrms.Text3.Text = c

d = za

Checks:

Exit Sub

End Sub

Function COMPUTE_TOTAL15(xa As Double, ya As Double, ha As Double, wa As Double, V As Double, n1 As Double, n2 As Double) As Integer

Dim C As Integer

tasfrms.vieform.Line (V, n2)-(wa, ha), QBColor(12), BF

tasfrms.vieform.Line (V, n2)-(wa, ha), QBColor(3), BF

a = xa

b = ya

Y = 0

C = 0

Y1 = b

Do While Y1 <= ha

X = V

X1 = V + a

Do While X1 <= wa

Call SHOWBOX(X, Y, X1, Y1)

C = C + 1

X = X1

X1 = X1 + a

Loop

Y = Y1

Y1 = Y1 + b

Loop

COMPUTE_TOTAL15 = C

End Function

Function COMPUTE_TOTAL211(xa As Double, ya As Double, ha As Double, wa As Double, V As Double, n1 As Double, n2 As Double) As Integer

Dim C As Integer

tasfrms.vieform.Line (n1, V)-(wa, ha), QBColor(12), BF

tasfrms.vieform.Line (n1, V)-(wa, ha), QBColor(3), BF

a = xa

b = ya

Y = V

C = 0

Y1 = V + b

Do While Y1 <= ha

X = 0

X1 = a

Do While X1 <= wa

Call SHOWBOX(X, Y, X1, Y1)

C = C + 1

X = X1

X1 = X1 + a

Loop

Y = Y1

Y1 = Y1 + b

Loop

COMPUTE_TOTAL211 = C

End Function

Sub SHOWBOX(ByVal X As Double, ByVal Y As Double, ByVal X1 As Double, ByVal Y1 As Double)

tasfrms.vieform.Line (X, Y)-(X1, Y1), QBColor(8), BF

tasfrms.vieform.Line (X, Y)-(X1, Y1), QBColor(0), B

tasfrms.vieform.Line (X + 3, Y + 3)-(X1 - 3, Y1 - 3), QBColor(7), BF

tasfrms.vieform.Line (X + 3, Y + 3)-(X1 - 3, Y1 - 3), QBColor(0), B

tasfrms.vieform.Line (X, Y)-(X + 3, Y + 3), QBColor(0)

tasfrms.vieform.Line (X1, Y1)-(X1 - 3, Y1 - 3), QBColor(0)

tasfrms.vieform.Line (X, Y1)-(X + 3, Y1 - 3), QBColor(0)

tasfrms.vieform.Line (X1, Y)-(X1 - 3, Y + 3), QBColor(0)

End Sub

to execute the code

'first option

Private Sub Command1_Click()

Call COMPUTE_TOTAL44(tasfrms.Text1.Text, tasfrms.Text2.Text, tasfrms.Text4.Text, tasfrms.Text5.Text, 2)

end sub

'second option

Private Sub Command2_Click()

Call COMPUTE_TOTAL44(tasfrms.Text2.Text, tasfrms.Text1.Text, tasfrms.Text4.Text, tasfrms.Text5.Text, 0)

End Sub

'third option

Private Sub Command3_Click()

Call COMPUTE_TOTAL44(tasfrms.Text2.Text, tasfrms.Text1.Text, tasfrms.Text5.Text, tasfrms.Text4.Text, 1)

End Sub

'fourth option

Private Sub Command4_Click()

Call COMPUTE_TOTAL44(tasfrms.Text1.Text, tasfrms.Text2.Text, tasfrms.Text5.Text, tasfrms.Text4.Text, 1)

End Sub

Capture.PNG

Capture.PNG