Jul 26th, 2005, 05:35 AM
#1
Thread Starter
PowerPoster
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
Jul 26th, 2005, 05:50 AM
#2
Re: Plotting points in picturebox
But to plot points you need two values. One x and one y. You only supplied one value.
Jul 26th, 2005, 05:54 AM
#3
Thread Starter
PowerPoster
Re: Plotting points in picturebox
my mistake. Does this help?
10,50
20,80
30,65
40,55
50,95
Jul 26th, 2005, 06:06 AM
#4
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:
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:
Picture1.Line (10, Picture1.ScaleHeight - 50)-(20, Picture1.ScaleHeight - 80)
Jul 26th, 2005, 06:08 AM
#5
Thread Starter
PowerPoster
Re: Plotting points in picturebox
Thanks, i'll see how I go.
Jul 26th, 2005, 07:05 AM
#6
Thread Starter
PowerPoster
Re: Plotting points in picturebox
Thanks Joacim, got the basics using the below and will now modify to meet my requirements.
VB Code:
Private Sub Form_Load()
Picture1.ScaleHeight = 100
Picture1.ScaleWidth = 100
Picture1.Line (10, 50)-(20, 80)
Picture1.Line (20, 80)-(30, 65)
Picture1.Line (30, 65)-(40, 55)
Picture1.Line (40, 55)-(50, 95)
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
Forum Rules
Click Here to Expand Forum to Full Width