Current location - Training Enrollment Network - Mathematics courses - How to solve a quadratic equation with one variable by VB?
How to solve a quadratic equation with one variable by VB?
Change the two equations into the standard form: AX+BY+C=0, plus Text 1-Text8, which are the x-term coefficient, y-term coefficient, constant term of equation 1 and the solutions of x and y of equation 2 in turn.

Add a button using the following code:

Private subcommand 1_Click ()

Dim A 1 is single, A2 is single, B 1 is single, B2 is single, C 1 is single, C2 is single.

A 1 = Val(Text 1)

A2 = Val (text 4)

B 1 = Val(Text2)

B2 = Val (Text 5)

C 1 = Val(Text3)

C2 = Val (Text 6)

If A 1 * B2-A2 * B 1 = 0, then

If b1* C2-B2 * c1<; & gt0 and then MsgBox "The equations have no solution!" : outlet connector

If b 1 * C2-B2 * C 1 = 0, then msgbox "The equations have infinite groups without solutions!" : outlet connector

If ... it will be over.

text 7 =(b 1 * C2-B2 * c 1)/(a 1 * B2-A2 * b 1)

text 8 =(A2 * c 1-a 1 * C2)/(a 1 * B2-A2 * b 1)

End joint