I am trying to calculate the price of a pizza based on the following table.
I am using a two dimensional array and the following code. I am getting an array out of bounds error. Can anyone help? Thanks in advance!
Code:
Small Medium Large Monster Regular 5.99 6.99 7.99 8.99 Stuffed Crust 7.99 8.99 9.99 10.99
Code:
Dim pizzaArrayDecimal(,) As Decimal = {{5.99, 6.99, 7.99, 8.99}, _ {7.99, 8.99, 9.99, 10.99}} Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click 'Look up the pizza price Dim SizeIndexInteger As Integer Dim StyleIndexInteger As Integer SizeIndexInteger = cboSize.SelectedIndex StyleIndexInteger = cboStyle.SelectedIndex If SizeIndexInteger <> -1 And StyleIndexInteger <> -1 Then pizzaTextBox.Text = pizzaArrayDecimal(SizeIndexInteger, StyleIndexInteger).ToString("N") Else MessageBox.Show("Select the Size and Style.", "Information Missing", _ MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If End Sub
Comment