Hello. My project is like this. When I select from "TypeComboBox" and "BeanComboBox", the "PriceTextBox" will display the appropriate amount of the "Private PriceDecimal". But when I added the "Private SnackPrice", it will display only the 1st array, (0, 0) for both array. I try using "Select Case" but doesn't work. I don't know what the problem is. Or maybe it can't be done like this? One structure can have one array? Please help.

Private TransactionCoffeeSale(30) As CoffeeSale
    Private NumberTransactionsInteger As Integer
    Private SnackPrice(,) As Decimal = {{1D, 2D}, {3D, 4D}}
    Private PriceDecimal(,) As Decimal = {{2.6D, 2.9D, 3.25D}, {4.9D, 5.6D, 6.1D}, {8.75D, 9.75D, 11.25D}}

    Structure CoffeeSale
        'Beans
        Dim TypeString As String
        Dim QuantityString As String
        Dim PriceDecimal As Decimal
        Dim SnackString As String
        Dim NumString As String
        Dim SnackPrice As Decimal
    End Structure

    Private Sub FindButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindButton.Click
        Dim RowInteger, ColumnInteger, SnackRow, SnackColumn As Integer
        Dim SalePriceDecimal As Decimal

        If ColumnInteger = TypeComboBox.SelectedIndex Then
            If ColumnInteger <> -1 Then
                If Me.BeanComboBox.Text = "Quater pound" Then
                    RowInteger = 0
                    TransactionCoffeeSale(NumberTransactionsInteger).QuantityString = "Quater Pound"
                ElseIf Me.BeanComboBox.Text = "Half pound" Then
                    RowInteger = 1
                    TransactionCoffeeSale(NumberTransactionsInteger).QuantityString = "Half Pound"
                ElseIf Me.BeanComboBox.Text = "Full pound" Then
                    RowInteger = 2
                    TransactionCoffeeSale(NumberTransactionsInteger).QuantityString = "Full Pound"
                End If

                SalePriceDecimal = PriceDecimal(RowInteger, ColumnInteger)
                PriceTextBox.Text = SalePriceDecimal.ToString("C")

                TransactionCoffeeSale(NumberTransactionsInteger).TypeString = TypeComboBox.Text
                TransactionCoffeeSale(NumberTransactionsInteger).PriceDecimal = SalePriceDecimal
                NumberTransactionsInteger += 1

                ClearButton.Enabled = True

            Else
                MessageBox.Show("Select the coffee type.", "Selection incomplete.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If
        ElseIf SnackColumn = SnackComboBox.SelectedIndex Then
            If SnackColumn <> -1 Then
                If Me.NumComboBox.Text = "1" Then
                    SnackRow = 0
                    TransactionCoffeeSale(NumberTransactionsInteger).NumString = "1"
                ElseIf Me.NumComboBox.Text = "2" Then
                    SnackRow = 1
                    TransactionCoffeeSale(NumberTransactionsInteger).NumString = "2"
                End If
                SalePriceDecimal = SnackPrice(SnackRow, SnackColumn)
                PriceTextBox.Text = SalePriceDecimal.ToString("C")

                TransactionCoffeeSale(NumberTransactionsInteger).SnackString = SnackComboBox.Text
                TransactionCoffeeSale(NumberTransactionsInteger).SnackPrice = SalePriceDecimal
                NumberTransactionsInteger += 1

                ClearButton.Enabled = True

            Else
                MessageBox.Show("Select the snack type.", "Selection incomplete.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If
        End If
    End Sub
Member Avatar for Unhnd_Exception

With out looking at it to much I can tell you this.


Your If Statement:

If ColumnInteger = TypeComboBox.SelectedIndex Then

Is only going to happen if the .SelectedIndex = 0.
Your not assinging anything to ColumnInteger or SnackRow and the default value for integer is 0.

Maybe you are wanting.

ColumnInteger = TypeComboBox.SelectedIndex

If ColumnInteger <> -1 Then

When I do that, after selected TypeComboBox and BeanComboBox then click button, it will pop-up message box saying I need to select SnackComboBox. So I just delete the message box part and it work.

Thank you. >_<

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.