Results 1 to 6 of 6

Thread: Plotting points in picturebox

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Plotting points in picturebox

    I've searched for how to plot points in a picturebox and then join then (a mini graph) without any luck.

    Does anyone have an example to get me started?

    Attached is what I'm trying to achieve. In the example values could be..

    1. 50
    2. 80
    3. 65
    4. 55
    5. 95
    Attached Images Attached Images  

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Plotting points in picturebox

    But to plot points you need two values. One x and one y. You only supplied one value.

  3. #3

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Plotting points in picturebox

    my mistake. Does this help?

    10,50
    20,80
    30,65
    40,55
    50,95

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Plotting points in picturebox

    OK. If you store those coordinates you could just use the Line method to draw a line from one point to the next.
    VB Code:
    1. Picture1.Line (10, 50)-(20, 80)
    Of course you need to change the ScaleMode of the picture box. Also since the (0, 0) corner is the upper left corner instead of the lower left you might want to recalculate the second point.
    VB Code:
    1. Picture1.Line (10, Picture1.ScaleHeight - 50)-(20, Picture1.ScaleHeight - 80)

  5. #5

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Plotting points in picturebox

    Thanks, i'll see how I go.

  6. #6

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Resolved Re: Plotting points in picturebox

    Thanks Joacim, got the basics using the below and will now modify to meet my requirements.

    VB Code:
    1. Private Sub Form_Load()
    2.  
    3. Picture1.ScaleHeight = 100
    4. Picture1.ScaleWidth = 100
    5.  
    6. Picture1.Line (10, 50)-(20, 80)
    7. Picture1.Line (20, 80)-(30, 65)
    8. Picture1.Line (30, 65)-(40, 55)
    9. Picture1.Line (40, 55)-(50, 95)
    10. 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