Question
Visual Basic says I have no errors but it won't work properly when I debug. Please help. Public Class Form1 'Substances' Dim substance() As String
Visual Basic says I have no errors but it won't work properly when I debug. Please help.
Public Class Form1 'Substances' Dim substance() As String = {"Ethyl alcohol", "Mercury", "Oxygen", "Water"}
'freezing points' Dim freezingPoint() As Double = {-173, -38, -362, 32}
'boiling points' Dim BoilingPoint() As Double = {172, 676, -306, 212} Private Sub BtnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click If txtTemp.Text <> "" Then 'gets temp from text box' Dim temperature As Double = CDbl(txtTemp.Text) Dim text As String = ""
'identifying freezing points of substance' Dim freezText As String = "" For i = 0 To substance.Length - 1 If freezingPoint(i) >= temperature Then If freezText = "" Then freezText = substance(i) Else 'replaces occurances of first parameter with second parameter' freezText = freezText.Replace(" and ", ", ") freezText = freezText + " and " + substance(i).ToLower() End If End If Next
'preparing freezing substances text' If Not freezText = String.Empty Then text = freezText + " will freeze" End If
Dim boilText As String = ""
' Identifying boiling points of substance' For i = 0 To substance.Length - 1 If BoilingPoint(i) <= temperature Then If boilText = "" Then boilText = substance(i).ToLower Else 'replaces occurances of first parameter with second parameter' boilText = boilText.Replace(" and ", ", ") boilText = boilText + " and " + substance(i).ToLower() End If
End If
Next
'display freezing and boiling text' If Not boilText = String.Empty Then If text <> "" Then text = text + " and " + boilText + " will boil " Else text = boilText + " will boil " End If Else text = text + "." End If
'display text as output' ListBox1.Text = text Else 'if temp not given' MessageBox.Show("Please enter temperature, Info") End If End Sub
End Class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started