Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays of Lines help

Status
Not open for further replies.

crystals

Programmer
Nov 30, 2000
7
0
0
US
I am copy pasting lines to create an array of 4000 lines. This is very time consuming. Is can't figure out the code to create an array of 4000 line objects. Can someone help?

Ctrlc, ctrlv '' '' '' '' ''


aarrgh.

sincerely,

roger norlund
 
If you want to view the lines in design mode then you will have to persevere. If you know where they are to be placed, you can do one of two things (that I know of):

1. Use the Line method of the form:
Private Sub Command1_Click()
Me.Line (200, 0)-(200, 200), 1000, B
End Sub


2. Create a control array (add 1 line control to your form and set the index property to 0) and then add more lines by using Load control (to use the code below, draw a line on your form and rename it to shpLine and set the idex property of the line to 0):

Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 20
Load shpLine(i)
shpLine(i).X1 = shpLine(i - 1).X1 + 50
shpLine(i).X2 = shpLine(i - 1).X2 + 50
shpLine(i).Visible = True
Next i
End Sub


Simon
 
crystals,

Hmmmm.

4000 lines? Do you really mean "lines", as in the line control (a control Array)? Or are we speaking "lines" of text (an array of strings)?

I KNOW you said the former, but I can't conceive of a 'real' use for that many 'line objects'.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Yes, i meant lines (as in the objects). Each square of my grid has 4 lines associated with it because i am trying to make a maze program. Do you think this is a bad way to go about it?

-C
 
If you want squares, you only need to call Line once (passing parameters for the top left corner and bottom right corner, and after the colour, put , B - meaning draw a box.

OR, create a square on your form, then you only have to do 1000 load statements, instead of 4000!!!!

Simon
 
crystals,

I have never considered making a (graphic) maze in VB. It could be interesting, in the logic to decide how many complete) real paths there should be - and then assuring there were EXACTLY that many.

There are probably a large number of soloutions/approaches, so wheather your approach is good/bad is more a matter of 'taste' than anything objective. This is certainly true of the information in this thread.

I would probably start with some parameters for the maze, and set up the process based on the parameters. Again, I have never considered creating a graphis maze in VB, so these thoughts are rather spontaneous. Perhaps you already have the experience of constructing mazes in other media and 'know' how you do this.

If I understood your process, perhaps I could comment on the approach.

I have generated generic "graph" paper from VB, and this does not require any elegance at all, but just setting start/end point values for vertical & horizontal lines (e.g. thier lenghts). Setting the current X & Y values for the printer, and printing sucessive lines untill you reach the end point. Start over for the other axis.

From this erspective, I would probably generate the array of points for the grid squares and a flag to denote to print/not print the segment. Sizing the array and filling the points array would come from the 'size' of the maze. Logic to denote wheather to print a given segment would come from your experience. Once the logic had marked the line segments to print (or not), I would just loop through the array and print the segments marked to print.



MichaelRed
mred@duvallgroup.com
There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top