Results 1 to 3 of 3

Thread: Need help with lines.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Posts
    123
    Ok here's my dilema,

    I need to draw a series of 20 parrallel lines in a picture box at a spacing of 30 twips on form load.

    Here's the code I have but it ain't drawing a single
    line...

    Dim sngX As Single, sngY As Single

    Private Sub Form_Load()
    sngX = 0
    sngY = 0
    For i = (1) To (20)
    picMap.Line (sngX, sngY)-(sngX + 30, sngY)
    intX = intX + 30
    intY = intY + 30
    Next i
    End Sub


  2. #2
    Junior Member
    Join Date
    Aug 2000
    Location
    Girona
    Posts
    18

    Smile

    Two comments:

    -If the code is correct, you use in the line method variables sngX and sngY and after you add 30 at other variables.

    -When you show a form, first you load the form into memory and after you show the form. It means, the form is loaded, you draw in the form and then the form is cleared to show itself, this is why this code don't draw anything.

    You may put this code in the event Form_Activate or in the event Form_Paint. I try to put the code in the event Form_Activate and works well.

    [Sorry for my english]


  3. #3
    Lively Member
    Join Date
    Jul 2000
    Posts
    94
    Using twips these are almost too small to see. Make sure that Autoredraw is set to true on the picture box. Also where you have intX and intY did you mean to have sngX and sngY? That was the only way I could get it to work. Try turning option explicit on. It will require you to declare all your variables, and can help you find typos.
    In twips they are there, but really really small.
    Here is what I have to get them to show in pixels
    Code:
    Private Sub Form_load()
        picmap.AutoRedraw = True
        sngX = 0
        sngY = 0
        For i = (1) To (20)
            picmap.Line (sngX, sngY)-(sngX + 30, sngY)
            sngX = sngX
            sngY = sngY + 30
        Next i
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width