I'm trying to right a program with Multidimensional Arrays.

These are the instructions for the program:
The Valley Boulevard (VB) Auto Center management is pleased with your progress in developing their system. They require you to develop a new feature for their system.

Main Form. The main form for this project is shown below. VB Auto sells its own brand of spark plugs. In order to allow system users to cross-reference to major brands, the firm keeps a table of equivalent part numbers. You are to computerize the process of looking up part numbers in order to improve customer service.

Requirements. Name the project VBAutoLab8 + YourLastName – for example, if your last name is Bock, name the project VBAutoLab8Bock.

System Startup. The system will start up with the Their Part Number textbox blank (this currently displays RJ6) and NO Brand selected by default (none of the radio buttons are checked). Likewise, the Our VB Part Number display label (this currently displays the value PR223) for output will be blank. On startup, the cursor (focus) should be set to the textbox. The tab order should be Their Part Number textbox, Brand radio buttons, Lookup button, Clear button, then Exit button.
Lookup button – system operation. The system user will:
Enter the competitor's part number for that brand into the input textbox that is provided on the form shown above.
Select the brand by clicking one of the radio buttons.
Click the Lookup button - the system should display the equivalent VB Part Number to the output label shown above.
The lookup should work even if Their Part Number is NOT entered in capital letters.
Your code must use a search technique taught in the chapter, not simply a long series of IF statements. The program code for the lookup procedure must use a condition-controlled loop.
Display an appropriate error message such as “Reenter Their Part Number and Check Brand” if the lookup fails to find a match. Also display the OK button and Critical Error icon as part of the message box.
Clear button. When this button is clicked, clear the brand radio button selection so that none of the radio buttons are selected, clear the textbox and output display label, and set the focus back to the textbox.
Exit button. When this button is clicked, end the application.
Data Storage. Store the part numbers in a two-dimensional table (array). The data for the system may be loaded during the Form_Load event or you may wish to declare the array as a module-level array. Using the module-level array is probably easier as the approach will be similar to that used at the end of the Chapter 8 notes for the multi-dimensional array. The data for this application are given in the following table. Do not store the header row (Brand A, Brand C, etc) in the table as this is not part of the data.

I was able to create the table and set up the form part. But I can't actually figure out what code I'm suppose to use to make it execute properly. I've tried different methods and I just don't know how to call the index number and make the proper part show up in the VBAuto box!

HELP?!

Thank you for any and all help in advance!

HELP?!

"I've tried different methods and I just don't know how to call the index number and make the proper part show up in the VBAuto box!"
If you post what you've tried, we can help you get on the right track. Without seeing your attempts, we don't know where you've got a problem.
Alternatively, you can tell us the symptoms, and we'll help you find the right direction.

Public Class Form1

Public SparkPlugsString(,) As String = {{"VBAutoPart", "Brand A", "Brand C", "Brand X"},
{"PR214", "MR43T", "RBL8", "14K22"},
{"PR223", "R43", "RJ6", "14K24"},
{"PR224", "R43N", "RN4", "14K30"},
{"PR246", "R46N", "RN8", "14K32"},
{"PR247", "R46TS", "RBL17Y", "14K33"},
{"PR248", "R46TX", "RBL12-6", "14K35"},
{"PR324", "S46", "J11", "14k38"},
{"PR326", "SR46E", "XEJ8", "14K40"},
{"PR444", "47L", "H12", "14K44"}}

Private Property VerticalPrintLocationSingle As Object

Public Sub LookupButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LookupButton.Click
Dim PartIndexInteger As Integer
Dim BrandIndexInteger As Integer


BrandIndexInteger = BrandBox.SelectedIndex
PartIndexInteger = PartBox.SelectedIndex

If PartIndexInteger <> -1 And BrandIndexInteger <> -1 Then
VBAutoTextBox.Text =
SparkPlugsString(PartIndexInteger, BrandIndexInteger).ToString("")
Else
MessageBox.Show("Select the Part and Brand.", "Information Missing", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
End If
End Sub
End Class

This is pretty much what I have.. But I just can't figure it out :-/

I'm a pretty big beginner at this... I tried looking up tutorials (thank you very much for that by the way) and couldn't find what I was looking for...

You have created a multi-dimensional array for the equivalent part numbers.

You will need to search the table for the competitive part number, if there is a match, you will display your own brand's part number. That's the idea.

In practice, you need a for loop to go through all the parts until you find the competitive part number. Then return your own brand.

In more sophisticated systems, the search will not be a sequential search, but more like a binary search on a sorted list or index. For now, with less than 500 parts, efficiency is not a problem.

You must have learned about sequential search and multi-dimensional arrays.

Give it a try, and post what you have. Your current code shows the search of only one item, without searching through the who array. So perhaps you might even have syntax error.

To help you with your program, let's break down the steps you need to follow:

1. Set up the form:
- Create a form with the required controls: textbox, radio buttons, buttons, and label.
- Set the default values and focus on the textbox.
- Arrange the tab order according to the requirements.

2. Create the two-dimensional array:
- Declare a module-level array to store the part numbers.
- Initialize the array with the given data in the table (excluding the header row).

3. Implement the lookup functionality:
- Write a function or subroutine to perform the lookup.
- Retrieve the competitor's part number from the textbox and convert it to uppercase.
- Determine the selected brand by checking the state of the radio buttons.
- Using a loop, search the array for a match for the competitor's part number and the selected brand.
- If a match is found, display the equivalent VB Part Number in the output label.
- If no match is found, display an error message with the OK button and Critical Error icon.

4. Implement the Clear button functionality:
- Clear the radio button selection.
- Clear the textbox and output display label.
- Set the focus back to the textbox.

5. Implement the Exit button functionality:
- End the application.

Now, let's see an example implementation in code. Keep in mind that this is just a general outline, and you may need to adjust it based on your specific requirements and programming language:

```python
# Step 2: Create the two-dimensional array
part_numbers = [
["AB12", "CD34", "EF56"],
["GH78", "IJ90", "KL12"],
["MN34", "OP56", "QR78"]
]

# Step 3: Implement the lookup functionality
def lookup_part():
their_part_number = textbox.get().upper()
brand = get_selected_brand()

for i, brand_row in enumerate(part_numbers):
for j, part_number in enumerate(brand_row):
if part_number == their_part_number:
vb_part_number = part_numbers[i][j]
output_label.set(vb_part_number)
return

# No match found
display_error_message()

# Helper function to get the selected brand from radio buttons
def get_selected_brand():
if brand_a_radio_button.get() == 1:
return "Brand A"
elif brand_b_radio_button.get() == 1:
return "Brand B"
elif brand_c_radio_button.get() == 1:
return "Brand C"

# Step 4: Implement the Clear button functionality
def clear_fields():
brand_a_radio_button.deselect()
brand_b_radio_button.deselect()
brand_c_radio_button.deselect()
textbox.set("")
output_label.set("")
textbox.focus()

# Step 1: Set up the form (create controls, set default values, etc.)

# Step 5: Implement the Exit button functionality
def exit_program():
window.quit()

# Finally, wire up the buttons to their respective functions/subroutines
lookup_button.configure(command=lookup_part)
clear_button.configure(command=clear_fields)
exit_button.configure(command=exit_program)
```

Note: The code provided is just an example and may not directly fit your programming language or framework. You will need to adapt the code and syntax to fit your specific programming environment.

I hope this helps! Let me know if you have any further questions.