Mwagner5600
Member
- Joined
- Mar 6, 2004
- Messages
- 5
I have a programm where I need to keep a running total of the quantity and the total. I will paste the code I have so far.
_________________________________________________
Option Strict On
Public Class frmCalorieCounter
Inherits System.Windows.Forms.Form
" Windows Form Designer generated code "
Const mintFAT As Integer = 9
Const mintCARBS_PROTIEN As Integer = 4
Dim mintQuantity As Integer
Dim mintTotalCalories As Integer
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Calculates the amount of Calories
Try
Dim intFat As Integer
Dim intCarbs As Integer
Dim intProtien As Integer
Dim intQuantity As Integer
Dim intTotalCalories As Integer
Dim intCalories As Integer
Convert inputValues to numeric variables
intFat = CInt(txtFat.Text)
intCarbs = CInt(txtCarbs.Text)
intProtien = CInt(txtProtien.Text)
Calculate Values
intCalories = intFat * mintFAT + intCarbs * mintCARBS_PROTIEN + intProtien * mintCARBS_PROTIEN
intQuantity = intFat + intCarbs + intProtien
intTotalCalories = intCalories
Format and Display answers
lblCalories.Text = FormatNumber(intCalories, 0)
lblQuantity.Text = FormatNumber(mintQuantity, 0)
lblTotalCalories.Text = FormatNumber(mintTotalCalories, 0)
Catch MyErr As Exception
MsgBox("Try to re-enter your data", MsgBoxStyle.Exclamation, "Data Error")
End Try
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Closes the Programm
Me.Close()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
Clears Proporties
lblCalories.Text = ""
txtProtien.Clear()
txtCarbs.Clear()
With txtFat
.Clear()
.Focus()
End With
End Sub
End Class
__________________________________________________________
I will attatch what my form looks like
I need to keep a running total of the mintquantity and mintTotalCalories
Sorry this is a little basic for all of you but im new to this programm and needed a little help.thanks
Mark
Edit-Sorry it is the summary part that needs to be the running total that i cant figure out
_________________________________________________
Option Strict On
Public Class frmCalorieCounter
Inherits System.Windows.Forms.Form
" Windows Form Designer generated code "
Const mintFAT As Integer = 9
Const mintCARBS_PROTIEN As Integer = 4
Dim mintQuantity As Integer
Dim mintTotalCalories As Integer
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Calculates the amount of Calories
Try
Dim intFat As Integer
Dim intCarbs As Integer
Dim intProtien As Integer
Dim intQuantity As Integer
Dim intTotalCalories As Integer
Dim intCalories As Integer
Convert inputValues to numeric variables
intFat = CInt(txtFat.Text)
intCarbs = CInt(txtCarbs.Text)
intProtien = CInt(txtProtien.Text)
Calculate Values
intCalories = intFat * mintFAT + intCarbs * mintCARBS_PROTIEN + intProtien * mintCARBS_PROTIEN
intQuantity = intFat + intCarbs + intProtien
intTotalCalories = intCalories
Format and Display answers
lblCalories.Text = FormatNumber(intCalories, 0)
lblQuantity.Text = FormatNumber(mintQuantity, 0)
lblTotalCalories.Text = FormatNumber(mintTotalCalories, 0)
Catch MyErr As Exception
MsgBox("Try to re-enter your data", MsgBoxStyle.Exclamation, "Data Error")
End Try
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Closes the Programm
Me.Close()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
Clears Proporties
lblCalories.Text = ""
txtProtien.Clear()
txtCarbs.Clear()
With txtFat
.Clear()
.Focus()
End With
End Sub
End Class
__________________________________________________________
I will attatch what my form looks like
I need to keep a running total of the mintquantity and mintTotalCalories
Sorry this is a little basic for all of you but im new to this programm and needed a little help.thanks
Mark
Edit-Sorry it is the summary part that needs to be the running total that i cant figure out
Attachments
Last edited by a moderator: