Hey guys, I'm making a nuclear reactor simulator application that also creates file output in an html table, which I'm almost done with, but have a few errors. I know the functions aren't right. Each formula needs its own function and my calling of functions isn't correct. I'm also making making a flow chart detailing functions, input, output, and all decisions, which I'm struggling with. Couldn't anybody provide some guidance or help? Thanks. Here's my code
[CODE]Imports System.IO
Imports System.Text
Public Class frmMain
Private tempadd As Double = 200
Private temp As Double = 0
Private PSI As Double = 0
Private RPM As Double = 0
Private Power As Double = 0
Private islog As Boolean
Private rod, gpm As Double
Dim s As StringBuilder = New StringBuilder()
Dim outfile As StreamWriter = New StreamWriter("Output.html", False)
Private Sub btnCIncrease_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCIncrease.Click
If PBCoolent.Value <= 1900 Then
PBCoolent.Value = PBCoolent.Value + 100
lblCoolentVal.Text = PBCoolent.Value
Else
MessageBox.Show("Maximum Coolant Level is Reached", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub btnCDecrease_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCDecrease.Click
If PBCoolent.Value >= 100 Then
PBCoolent.Value = PBCoolent.Value - 100
lblCoolentVal.Text = PBCoolent.Value
Else
MessageBox.Show("Minimum Coolant Level is Reached", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub btnRedIncrease_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRedIncrease.Click
If PBRod.Value <= 90 Then
PBRod.Value = PBRod.Value + 10
lblRedVal.Text = PBRod.Value & "%"
Else
MessageBox.Show("Maximum Rod Level is Reached", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub btnRedDecrease_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRedDecrease.Click
If PBRod.Value >= 10 Then
PBRod.Value = PBRod.Value - 10
lblRedVal.Text = PBRod.Value & "%"
Else
MessageBox.Show("Minimum rod Level is Reached", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblCoolentVal.Text = PBCoolent.Value
MakeHTMl()
End Sub
Private Function Coolent()
gpm = PBCoolent.Value
rod = PBRod.Value
If gpm < 500 Then
tempadd = ((500 - gpm) / 500 + 1) * tempadd
ElseIf gpm = 500 Then
tempadd = tempadd
ElseIf gpm > 600 Then
tempadd = (1 - ((gpm - 500) / 500)) * tempadd
End If
tempadd = tempadd - 30
temp = tempadd + temp
txtCoreTemp.Text = temp
Return Nothing
End Function
Private Function Calrod()
tempadd = (1 - (PBRod.Value / 100)) * 200
Return Nothing
End Function
Private Function CalPSI()
PSI = temp / 2
txtPsi.Text = PSI
Return Nothing
End Function
Private Function CalRPM()
RPM = PSI / 10
txtTRPM.Text = RPM
Return Nothing
End Function
Private Function PowerOut()
Power = RPM * 500
txtWatts.Text = Power
Return Nothing
End Function
Private Function coreStatus()
If temp < 500 Then
txtCore.Text = "Low Power"
ElseIf temp <= 800 Then
txtCore.Text = "Core Stable"
ElseIf temp <= 2500 Then
txtCore.Text = "Highly Reactive"
ElseIf temp <= 5999 Then
txtCore.Text = "Core Unstable"
Else
txtCore.Text = "Core Meltdown"
End If
Return Nothing
End Function
Private Function TurbineStatus()
If (RPM >= 225) Then
txtTStatus.Text = "Turbine Damaged"
ElseIf (RPM >= 50) Then
txtTStatus.Text = "Highspeed"
Else
txtTStatus.Text = "Turbine OK"
End If
Return Nothing
End Function
Private Sub timerCal_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles timerCal.Tick
Calrod()
Coolent()
CalPSI()
CalRPM()
PowerOut()
coreStatus()
TurbineStatus()
WriteData()
End Sub
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
timerCal.Enabled = True
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
timerCal.Enabled = False
End Sub
Private Sub btnStartLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartLog.Click
islog = True
End Sub
Private Sub btnStopLog_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStopLog.Click
islog = False
s.AppendLine("</html>")
Using outfile
outfile.Write(s.ToString())
End Using
End Sub
Private Sub WriteData()
If islog = True Then
s.AppendLine("<tr><td>" & temp & "</td><td>" & rod & "</td><td>" & PSI & "</td><td>" & Power & "</td><td>" & RPM & "</td><td>" & txtCore.Text & "</td><td>" & txtTStatus.Text & "</td> </tr>")
End If
End Sub
Private Sub MakeHTMl()
s.AppendLine("<html>")
s.AppendLine("<center><table border=1 style=width:300px>")
s.AppendLine("<tr><td> Temp </td><td> Rod </td><td>Psi</td><td>Power</td><td>rpm</td><td>status</td><td>turbine</td></tr>")
End Sub
End Class/CODE]