Professional Documents
Culture Documents
Login | Register
Find Code
Close
Submit Code
ASP, HTML
and XML
Database
Dates and
Math
Files and
Directories
Forms and
Controls
Lists,
Collections
and Arrays
Miscellaneous
Multimedia /
Games
Network /
Internet
Office/VBA
Registry
Screen /
Graphics
String
Manipulation
System API
VB.NET /
ASP.NET
Windows
2000/XP
The changing face of BI: Predictive Analytics, Cognitive Services, and AI. Download your free eBook today!
Difficulty:
Beginning
Author:
Noah Amolo
More information:
This snippet of code is used for solving quadratic ecuations. Add 3
textbox controls and a command button to demo this sub
procedure.
Declarations:
Dim a As Double, b As Double, c As Double, x1 As Double, x2 As
Double
Dim message As String
Code:
Private Sub cmdProcess_Click()
a = Val(txtA.Text)
b = Val(txtB.Text)
c = Val(txtC.Text)
message = "There is no solution to your equation"
If ((b ^ 2) - (4 * a * c)) < 0 Then
MsgBox message, vbOKOnly, "Error"
Else
x1 = Round((-b + Sqr(b ^ 2 - 4 * a * c)) / (2 * a), 2)
x2 = Round((-b - Sqr(b ^ 2 - 4 * a * c)) / (2 * a), 2)
lblResult1.Caption = x1
lblResult2.Caption = x2
End If
End Sub
Planning a Successful
ERP Implementation