I am trying to use different buttons to assign different values to a variable.
There are 2 variables using different buttons to assign them.
These variables are being added together to assign value to a label.
I believe my error is in my syntax but I have not found out how to use a button to set the value for a variable.
I get no error codes, I just do not get a result in my final label. It stays blank.
Here is a chunk of my code:
Expand|Select|Wrap|Line Numbers
- Public Class frmLunchCombos
- ‘I went ahead and defined my variables
- Dim dblSandwichCost As Double
- Dim dblSoupCost As Double
- 'Click TomatoBasil
- Private Sub btnTomatoBasil_Click(sender As Object, e As EventArgs) Handles btnTomatoBasil.Click
- ‘I mean for this to set SoupCost to the value 2.49
- dblSoupCost = 2.49
- End Sub
- 'Click ClassicTurkeyBreast
- Private Sub btnClassicTurkeyBreast_Click(sender As Object, e As EventArgs) Handles btnClassicTurkeyBreast.Click
- ‘I mean for this to set SandwichCost to the value 3.49
- dblSandwichCost = 3.49
- End Sub
- Private Sub lblCalcSubtotal_Click(sender As Object, e As EventArgs) Handles lblCalcSubtotal.Click
- ‘I made dblValue for easy formatting of the final label
- Dim dblValue As Double
- ‘Value= SoupCost (which would be assigned to 2.49 after clicking Tomato Basil) + SandwichCost (which would be assigned to 3.49 after clicking ClassicTurkeyBreast)
- dblValue = dblSoupCost + dblSandwichCost
- ‘And then convert Value to a currency-formatted string
- lblCalcSubtotal.Text = dblValue.ToString("C")
- End Sub