drawing a zigzag line

Any help with drawing zigzag lines would be heplful. I am absolutely clueless and desperate!!!
thanks


Comments

  • The following code will make zig zag lines from left to right with line objects.

    You will need to have a line object on a form, with it's Index property set to 0.

    Also have a command button on the form, to act as the executor.

    The parameters in the Form load can be changed according to what zig zag line you want.

    [code]Dim intnumoflines As Integer 'Counter to keep track of how many zig zags have currently been made.
    Dim intfarx, intfary As Integer 'intfarx = length of each zig across, intfary = height of each zig up (and down).
    Dim intwantedzigzags As Integer 'Amount of lines wanted in the zig zag.
    Dim bolzigorzag As Boolean 'If true the line will zig (go up) if false the line will zag (go down).
    Private Sub Form_Load()
    intfarx = 10 'Length of zig zags.
    intfary = 10 'Height of zig zags.
    intwantedzigzags = 20 'Amount of zig zags in line.
    End Sub
    Private Sub Command1_Click()
    Do Until intnumoflines = intwantedzigzags 'Keep looping until the number of zig zags is equal to the amount wanted.
    createnewline 'Calls procedure to make a new zig or zag.
    Loop
    End Sub
    Sub createnewline()
    intnumoflines = intnumoflines + 1 'Increment current number of lines in zig zag.
    Load Line1(intnumoflines) 'Creates a Line control object with a new index value.
    If bolzigorzag = True Then 'If line is going to zig (go up).
    Line1(intnumoflines).X1 = Line1(intnumoflines - 1).X2 'Makes the start of the new line, to be the end of the previous line.
    Line1(intnumoflines).Y1 = Line1(intnumoflines - 1).Y2 'Makes the start of the new line, to be the end of the previous line.
    Line1(intnumoflines).X2 = (Line1(intnumoflines).X1 + intfarx) 'Makes the end of the new line, to be the start of the new line + wanted zig length.
    Line1(intnumoflines).Y2 = (Line1(intnumoflines).Y1 + intfary) 'Makes the end of the new line, to be the start of the new line + wanted zig height.
    Line1(intnumoflines).Visible = True 'Make this new control to be visible.
    bolzigorzag = False 'Make next line be a zag (go down).
    Else
    Line1(intnumoflines).X1 = Line1(intnumoflines - 1).X2
    Line1(intnumoflines).Y1 = Line1(intnumoflines - 1).Y2
    Line1(intnumoflines).X2 = (Line1(intnumoflines).X1 + intfarx)
    Line1(intnumoflines).Y2 = (Line1(intnumoflines).Y1 - intfary) 'Notice - intfary, because the line is a zag (going downwards).
    Line1(intnumoflines).Visible = True
    bolzigorzag = True 'Make next line be a zig (go up).
    End If
    End Sub[/code]

  • Make sure to set the Form's ScaleMode property to Pixel instead of Twip(Default).

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion