How to draw a intersection point on two cures?
hi,I want to draw the point of intersection on two cures.For example,the point of inersection on Line y=x and parabola y=x*x (-2<=x<=2).But it is failure for the following program segment:
What's wrong with it? Hope to explain it.Thank you a lot.
For x=-2 to 2 step 0.01
If x=x*x then
Last edited by Hack; 03-08-2010 at 11:39 AM.
Reason: Added Code Tags
For one thing, x never gets incremented or decremented so it always has a value of -2
If you put a break on your code and step through it you will see that is ALWAYS hits the Else part, and x continues to equal -2
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
Not if x is defined as Double (or Float), in that case the loop works ok
Originally Posted by Hack
This is a classic rounding problem: the step is not a multiple of 2, therefore the test (x = x*x) will never be true (because incrementing by 0.01 x will never be zero)
This is one of the many ways (and not the best, but I did not want to change the code) to fix the problem:
Picture1.Scale (-2, 10)-(2, -10)
Dim x As Double
Dim dstep As Double
dstep = 2 ^ -6
For x = -2 To 2 Step dstep
If x = x * x Then
Picture1.ForeColor = vbRed
Picture1.ForeColor = vbBlack
Picture1.PSet (x, x * x)
"There are two ways to write error-free programs. Only the third one works."
By chupacabra in forum VB Classic
Last Post: 04-22-2009, 06:38 PM
By noobsaibot in forum .NET
Last Post: 09-16-2007, 10:01 PM
Last Post: 01-09-2007, 05:33 PM
Last Post: 05-31-2006, 06:07 PM
By Ad van Klink in forum .NET
Last Post: 09-01-2002, 09:52 AM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL