Log in

View Full Version : Programming help



Vladislav
21st March 2007, 07:55
Dunno if this is the right forum.Sorry if it's not.

Well the time has come for me to beg someone to do my homework for me. Not really, but I do need some help.

I have this major project due this Friday and I've hit a dead end.

This is the project:

A quadratic equation has the form y=ax2 + bx + c.

Develop a program to find the roots of any equation of this form. Your application should allow its user to type in the equation. It should provide users with feedback if the equation they enter is not valid. eg. b^2 - 4ac , can not be negative. Include error checking routines and help system.

Once the equation has been validated it should graph the quadratic equation.


I've done the first part of the code, but I have no idea how to graph it.
If anyone is willing to help then please do.If I get no reply then I'll just make some shit up and hand that in. Thanks in advance.

edit: This is the coding that I've done:


Private Sub cmdCalc_Click()
A = Val(txtA.Text)
b = Val(txtB.Text)
c = Val(txtC.Text)
f = Val((b ^ 2) - (4 * A * c))
g = Val((b ^ 2) - (4 * A * c))
j = Val(A)
If j = Val(0) Then
lblData1.Caption = "Not a quadratic equation. 'A' cannot equal 0."
Else
If Val(g) = 0 Then
d = Val(((-b + Sqr((b ^ 2) - (4 * A * c)))) / (2 * A))
e = Val(((-b - Sqr((b ^ 2) - (4 * A * c)))) / (2 * A))
lblAxa.Caption = d
lblAxb.Caption = e
Else
If Abs(g) = Val(-1 * g) Then
lblAxa.Caption = "imaginary"
lblAxb.Caption = "imaginary"
lblData1.Caption = "Imaginary numbers."
Else
d = Val(((-b + (((b ^ 2) - (4 * A * c)) ^ (1 / 2)))) / (2 * A))
e = Val(((-b - (((b ^ 2) - (4 * A * c)) ^ (1 / 2)))) / (2 * A))
lblAxa.Caption = d
lblAxb.Caption = e
End If
End If
End If




End Sub

Private Sub cmdClear_Click()
txtA.Text = ""
txtB.Text = ""
txtC.Text = ""
lblAxa.Caption = ""
lblAxb.Caption = ""
lblData1.Caption = ""
txtA.SetFocus

End Sub

Private Sub cmdExit_Click()
End
End Sub

Private Sub Form_Load()

End Sub

ComradeRed
21st March 2007, 17:58
What's the programming language?

[edit]: Ah VB 6, lemme see what I can find but I don't know it.

Chart and Graph Tutorial (http://www.lacher.com/toc/tutchart.htm)

SPK
21st March 2007, 18:48
The Chart and Graph Tutorial that CR linked seems to be for Visual Basic-Applications, which is an old VB implementation specific to Excel, Access, and other Office products. VBA is different from the Visual Basic 6.0 development environment, and its charting methods may be different as well.

I did a quick google and found the standard charting control that should come with the default VB 6.0 installation. You could use another, vendor-specific widget if you want to do something really complex, but core Microsoft controls usually are sufficient for at least the basic stuff.

In your VB project, go to Components and, under the Controls tab, select Microsoft Chart Control 6.0. The MSChart option will then appear in your Toolbox. I put one on a form, fiddled with its settings in the Properties Window, and got it to work with a simple dataset. You would have to control many of those properties directly in your code, of course.

Vladislav
30th March 2007, 05:27
Thanks for your help ComradeRed and SPK, I think I got it.

I did the coding and it seemed to sorta work. Had some minor problems,but fixed em.
Anyway I handed it in and I'll see what I get.

Thanks again.

ComradeRed
30th March 2007, 05:46
Why are you progamming in VB? Why don't you pull out your own teeth without anesthetic while your at it!

VB teaches you bad coding habits. It should be abolished from computer science all together.

Vladislav
30th March 2007, 06:57
yeah Vb is shitty, but our school makes us use it, so I'm stuck with it. That and Turbo Pascal + Liberty Basic.

JimFar
8th April 2007, 23:38
ComradeRed wrote:



Why are you progamming in VB? Why don't you pull out your own teeth without anesthetic while your at it!

Hey, Comrade, some of us make our living doing VB programming. However, I'll admit it's not my favorite programming language. Languages like C++ or Java or C# are much more elegant IMO, but VB isn't half bad for the kind of CGI web programming that I am doing in my current job.



VB teaches you bad coding habits. It should be abolished from computer science all together.

I kind of wondered why it was being used in what is apparently an intro programming course. VB is, of course, an easy language to pick up but its not the best language around for teaching people basic computer science concepts. Most schools use languages like C++ or Java for that purpose.