design

By | 2002-04-19

Creates a pretty neat geometric design!

Original Author: Haig Demerdjian

Inputs

The number of lines per side you wish to draw. You would enter it into a text box.

Assumptions

After you enter a number into the text box just click on draw and that’s it!

Code

' Before you start anything you should create: 1 picturebox, 1 textbox, 1 command button. Size the picture box so it is pretty big in size and it should be EXACTLY squared so the design looks nice! To do so make sure the scalewidth and scaleheight in the properties section are equal to each other. Now put the following code into the command button.
Private Sub Command1_Click()
If Text1 <= 0 Then Exit Sub
Picture1.Cls
w = Picture1.ScaleWidth / Text1
h = Picture1.ScaleHeight / Text1
' top to left
For draw = 0 To Text1
  Picture1.Line (0 + (w * draw), 0)-(0, Picture1.ScaleHeight - (h * draw))
Next draw
' left to bottom
For draw = 0 To Text1
  Picture1.Line (0, 0 + (h * draw))-(0 + (w * draw), Picture1.ScaleHeight)
Next draw
' bottom to right
For draw = 0 To Text1
  Picture1.Line (0 + (w * draw), Picture1.ScaleHeight)-(Picture1.ScaleWidth, Picture1.ScaleHeight - (h * draw))
Next draw
' right to top
For draw = 0 To Text1
  Picture1.Line (Picture1.ScaleWidth, 0 + (h * draw))-(0 + (w * draw), 0)
Next draw
End Sub

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.