'Trying to exclude specific array entries from combobox based on variables
I Have an array of strings in a combobox, I need to be able to have only certain ones appear based on other values from different arrays
Sorry if my explanation isn't very good, i'm not exactly sure how to word this question
Public PHOSOptions() As String = {"Express portrait shoot", "Standard portrait shoot", "Deluxe portrait shoot", "Family portrait shoot", "Childrens photo shoot", "Glam Photo shoot"}
Public PHOSPrice() As Int16 = {50, 95, 175, 140, 120, 280}
Public PHOSDuration() As Int16 = {30, 60, 120, 90, 60, 240}
These are the three arrays I need, the first is the names that show up in the combobox, I need to only show specific ones based on if when i input certain values that relate to the the other two arrays
Example being, I Input 200 as my max price and 120 as my max duration, which then only shows me options in the combo box that are either equal or below those two in this case that being all except for the last one
ComboBox1.MaxDropDownItems = PHOSOptions.Length
For stepper = 0 To (PHOSOptions.Length - 1)
ComboBox1.Items.Add(PHOSOptions(stepper))
Next
This Is how i'm populating the combobox
Solution 1:[1]
I Did Exactly as John in the comments recommended, remove the orignal way of populating the combobox, and just going through each one with a for loop to test them all
Dim MaxP As Int16 = TextBox1.Text
Dim MaxD As Int16 = TextBox2.Text
For stepper = 0 To (PHOSPrice.Length - 1)
If MaxP >= PHOSPrice(stepper) Then
If MaxD >= PHOSDuration(stepper) Then
ComboBox1.Items.Add(PHOSOptions(stepper))
End If
End If
Next
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Glenboi |