Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Please someone take a look, this code will give me errors in the lines where I put **.

 

Dim X, Y, g, h, slope, Err, ip As Double

Dim dx, dy, L, Max, n As Integer

Dim a, b, c, d, a1, b1 As Integer

Dim X1, X2, Y1, Y2, R As Integer

 

Sub Simple_DDA(a, b, c, d)

dx = c - a

dy = d - b

X = a

Y = b

slope = dy / dx

If dx > dy Then

g = 1

h = slope

Max = dx

Else

g = 1 / slope

h = 1

Max = dy

End If

 

For L = 1 To Max + 1

Picture1.PSet (Round(X), -Round(Y)), QBColor(2)

X = X + g

Y = Y + h

Next L

End Sub

 

Sub first_octant_dda(a, b, c, d) 'with anti aliasing

n = 2

dx = c - a

dy = d - b

Err = -(dx / 2)

a1 = a

b1 = b

Picture1.PSet (a1, -b1), QBColor(n)

Do While a1 < c

Err = Err + dy

If Err >= 0 Then

b1 = b1 + 1

Err = Err - dx

End If

a1 = a1 + 1

If Err > 0 Then

ip = n * (Err / dy)

End If

If Err = 0 Then

ip = 0

End If

If Err < 0 Then

ip = -n * (Err / dx)

End If

 

Picture1.PSet (a1, -b1), QBColor(Abs(Round(n - ip)))

Picture1.PSet (a1, -b1 + 1), QBColor(Abs(Round(ip)))

Loop

End Sub

 

 

Sub Plot8(a, b) 'Plotting points for circle method

Picture1.PSet (a, b), QBColor(1)

Picture1.PSet (-a, -b), QBColor(1)

Picture1.PSet (-a, b), QBColor(1)

Picture1.PSet (a, -b), QBColor(1)

Picture1.PSet (b, a), QBColor(1)

Picture1.PSet (-b, -a), QBColor(1)

Picture1.PSet (-b, a), QBColor(1)

Picture1.PSet (b, -a), QBColor(1)

End Sub

 

Sub Circle_method(X1, Y1, R)

d = 3 - (2 * R)

Do

Plot8 X1, Y1

If d > 0 Then

d = d + 4 * (X1 - Y1) + 10

Y1 = Y1 - 1

Else

d = d + 4 * X1 + 6

End If

X1 = X1 + 1

Loop While X1 < Y1

If X1 = Y1 Then

Plot8 X1, Y1

End If

End Sub

 

Private Sub Command1_Click() 'This is when the pixel button is clicked.

Picture1.ScaleHeight = 150

Picture1.ScaleWidth = 400

Picture1.ScaleTop = -75

Picture1.ScaleLeft = -200

 

X1 = Val(Text1.Text)

Y1 = Val(Text2.Text)

X2 = Val(Text3.Text)

Y2 = Val(Text4.Text)

 

Label6.Caption = X1

Label8.Caption = X2

 

Label11.Caption = Y1

Label12.Caption = Y2

 

If Option1.Value = True Then

Label6.Caption = X1

Label8.Caption = X2

Label11.Caption = Y1

Label12.Caption = Y2

first_octant_dda X1, Y1, X2, Y2

ElseIf Option2.Value = True Then

Label6.Caption = X1

Label8.Caption = X2

Label11.Caption = Y1

Label12.Caption = Y2

Simple_DDA X1, Y1, X2, Y2

ElseIf Option3.Value = True Then

R = Val(Text5.Text)

Circle_method X1, Y1, R

End If

 

End Sub

 

'The following is only for the input:

 

Private Sub Command2_Click() 'Clear screen

Picture1.Cls

End Sub

 

Private Sub Command3_Click() 'End program

End

End Sub

 

Private Sub Form_Load() 'Makes circle method results invisible

**Label14.Visible = False

**Text5.Visible = False

End Sub

 

Private Sub Option1_Click() 'First octant dda

Label3.Visible = True

Label4.Visible = True

Label14.Visible = False

Text3.Visible = True

Text4.Visible = True

Text5.Visible = False

Label5.Visible = True

Label7.Visible = True

Label9.Visible = True

Label10.Visible = True

Label11.Visible = True

Label12.Visible = True

End Sub

 

Private Sub Option2_Click() 'Simple dda

Label3.Visible = True

Label4.Visible = True

Label14.Visible = False

Text3.Visible = True

Text4.Visible = True

Text5.Visible = False

Label5.Visible = True

Label7.Visible = True

Label9.Visible = True

Label10.Visible = True

Label11.Visible = True

Label12.Visible = True

End Sub

 

Private Sub Option3_Click() 'Circle method

Label3.Visible = False

Label4.Visible = False

Text3.Visible = False

Text4.Visible = False

Text5.Visible = True

Label14.Visible = True

Label5.Visible = False

Label6.Visible = False

Label7.Visible = False

Label8.Visible = False

Label9.Visible = False

Label10.Visible = False

Label11.Visible = False

Label12.Visible = False

End Sub

  • *Experts*
Posted

What's the error? As far as I can tell, you've never declared Label14. Otherwise it looks fine unless you're using an inherited form with Label14 as a Private variable.

 

-Ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Guest
This topic is now closed to further replies.
×
×
  • Create New...