|
-
Aug 26th, 2007, 11:16 PM
#1
Thread Starter
Member
Can I draw smooth curve in VB?
Can I draw smooth x VS y curve in VB like smooth line curve in Pivot Chart in access? Or, can i use Pivot chart in VB?
-
Aug 26th, 2007, 11:32 PM
#2
Re: Can I draw smooth curve in VB?
What about using the intrinsic 'Circle()' function ? (you can specify an arc length)
-
Aug 26th, 2007, 11:36 PM
#3
Thread Starter
Member
Re: Can I draw smooth curve in VB?
can I draw any curve (2d xy curve) using circle? I have two coulmn X and Y in my table which have random values. I want to draw a smooth X Versus Y line curve.
-
Aug 26th, 2007, 11:37 PM
#4
Re: Can I draw smooth curve in VB?
-
Aug 26th, 2007, 11:38 PM
#5
Re: Can I draw smooth curve in VB?
Ahh, ok ignore (both) those posts
-
Aug 26th, 2007, 11:55 PM
#6
Re: Can I draw smooth curve in VB?
How about PSet() ?
You could iterate the x and y values and place a pixel on the screen (or other container).
Thinking that tru, you may end up without lines between the points - probably unwanted.
These may help: http://vbforums.com/search.php?searchid=1442707
-
Aug 27th, 2007, 03:40 AM
#7
Re: Can I draw smooth curve in VB?
if you place the dots close enough together it is a line
here is an example that plots a spiral. originally it was just dots (50 points per circle), but i change it to 5000 and it is a solid line (as far as you and i can see)
vb Code:
Sub extrasub()
Dim col() As Long, r1 As Double, r As Double, px As Double
Dim py As Double, cnt As Long, spir As Long, spirw As Double
Pic1.Cls
px = Pic1.Width / 2
py = Pic1.Height / 2
r = 0 ' diameter of circle to sample 0 to start at center
cnt = 5000 'no of point to sample in circle
spir = 5 ' no of rings in spiral
spirw = (py - r) / spir / cnt
'Text1(0).Move px, py
ReDim col(cnt * spir)
For i = 0 To cnt * spir - 1
r1 = 360 / cnt * (i) * radians '3.142 / 180
Pic1.PSet (px + r * Sin(r1), py - r * Cos(r1)), vbRed 'i used this to put a circle i could see for testing
col(i) = Pic1.Point(px + r * Sin(r1), py - r * Cos(r1))
r = r + spirw '(py - 1000) / spir / cnt
Next
End Sub
so you just need to plot enough points on your curve,
or else join the dots together change the code like this
vb Code:
If Not i = 0 Then Pic1.Line (psx, psy)-(px + r * Sin(r1), py - r * Cos(r1)), vbRed
' Pic1.PSet (px + r * Sin(r1), py - r * Cos(r1)), vbRed 'i used this to put a circle i could see for testing
'****
psx = px + r * Sin(r1): psy = py - r * Cos(r1)
declare psx and psy both as double
with 50 points on each circle
Last edited by westconn1; Aug 27th, 2007 at 03:44 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|