Option Explicit On
Option Strict On
Option Infer Off
Public Class MainForm
Private Sub exitButton_Click(sender As System.Object, e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub calcButton_Click(sender As System.Object, e As System.EventArgs) Handles calcButton.Click
'declare variables and constants
Const WaterChg As Double = 0.00175
Dim currentRead As Double
Dim prevRead As Double
Dim gallonsUsed As Double
Dim totalCharge As Double
'get the input from the text boxes
Double.TryParse(currentTextBox.Text, currentRead)
Double.TryParse(prevTextBox.Text, prevRead)
'calculate gallons used and total charge
If currentRead >= prevRead Then
gallonsUsed = currentRead - prevRead
totalCharge = gallonsUsed * WaterChg
'display gallons used and total charge
gallonsUsedLabel.Text = gallonsUsed.ToString()
totalChargeLabel.Text = totalCharge.ToString("C2")
Else
'show error message if currentRead is less than prevRead
messageLabel.Text = "Invalid Parameters: Current Reading must be less than Previous Reading!"
End If
End Sub
End Class
input current and prev reads
|
get inputs
|
if current read >= prev read
|
calculate current - previous = gallons used
total charge = gallons used * .00175
|
else
|
display Invalid Parameters
|
end if
|
display gallons used and total charge
what really sucked was I did that without comments at first and when there were errors I actually had to look through it hard to find out what was wrong :|
This is a thread that I found on another website I post at. It can be really really interesting. I thought it deserved a place here.
Post your random thoughts for the day here, or anything else that intrigues you.
For starters, is it possible to give constructive critism to someone who doesn't have a neck? I totally just walked by a girl who didn't. Someone isn't getting a necklace for Valentines day!
And who decided black and white can't be colors? I want to say a racist. I really do.