I have the code below that I want to have print on separate lines each time the find cost button is pushed. So if there are 10 weights entered using the find cost button I want all ten to print with a total at the end. I am not sure if I have the code setup properly to begin with so of that is not corretc please let me know
Public Class Form1
Private Weight As Decimal
Private Zone As Decimal
Private RowTotalDecimal(3)
Private ColumnTotalDecimal(4)
Dim ShippingDecimal(,) As Decimal =
{{1D, 1.5D, 1.65D, 1.85},
{1.58D, 2D, 2.4D, 3.05D},
{1.71D, 2.52D, 3.1D, 4D},
{2.04D, 3.12D, 4D, 5.01D},
{2.52D, 3.75D, 5.1D, 7.25D}}
Private Sub FindCostButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindCostButton.Click
Weight = WeightListBox.SelectedIndex
Zone = ZoneListBox.SelectedIndex
If Weight <> -1 And Zone <> -1 Then
ChargeTextBox.Text =
ShippingDecimal(Weight, Zone).ToString("N")
Else
MessageBox.Show("Please select a weight and zone.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Stop
)
For RowInteger As Integer = 0 To 3
For ColumnInteger As Integer = 0 To 4
RowTotalDecimal(RowInteger) += ShippingDecimal(Weight, Zone)
ColumnTotalDecimal(ColumnInteger) += ShippingDecimal(Weight, Zone)
Next ColumnInteger
Next RowInteger
End If
End Sub
Public Class Form1
Private Weight As Decimal
Private Zone As Decimal
Private RowTotalDecimal(3)
Private ColumnTotalDecimal(4)
Dim ShippingDecimal(,) As Decimal =
{{1D, 1.5D, 1.65D, 1.85},
{1.58D, 2D, 2.4D, 3.05D},
{1.71D, 2.52D, 3.1D, 4D},
{2.04D, 3.12D, 4D, 5.01D},
{2.52D, 3.75D, 5.1D, 7.25D}}
Private Sub FindCostButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindCostButton.Click
Weight = WeightListBox.SelectedIndex
Zone = ZoneListBox.SelectedIndex
If Weight <> -1 And Zone <> -1 Then
ChargeTextBox.Text =
ShippingDecimal(Weight, Zone).ToString("N")
Else
MessageBox.Show("Please select a weight and zone.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Stop
)
For RowInteger As Integer = 0 To 3
For ColumnInteger As Integer = 0 To 4
RowTotalDecimal(RowInteger) += ShippingDecimal(Weight, Zone)
ColumnTotalDecimal(ColumnInteger) += ShippingDecimal(Weight, Zone)
Next ColumnInteger
Next RowInteger
End If
End Sub