-
May 17th, 2021, 08:31 AM
#1
Thread Starter
Junior Member
Nested loop on mutiple combo box
Hello , newbie here, I have a project where a user will enter a model number in a textbox and if the model he enter "contain" specific code and compare it with element in a array, well the program will update the a combo box in the menu containing the same code, so the user know that the model number he enter is valid.
Then thing is , the model number contain multiple code separated in a specific order and update multiple combo box on the menu, my question is can I use multiple nested loop so when the first loop start and the model the user have user is found, it continue looking in the string looking for the next code,with another loop example:
Let say the user have enter in the textbox this: C-FI-A1-15-PP-ST-ST-RT
Here is the code to check:
Code:
Dim handleOptions() As String = {"PP","AP","WP"}
Dim slideArmsOptions() As String = {"TX","TZ","TY"}
For i As Integer = 0 To handleOptions.length -1
If TXB_CODE_ING.Contains(handleOptions(i)) Then
CMB_HandleOptions = handleOptions(i)
For j As Integer = 0 To slideArmsOptions.length -1
If TXB_CODE_ING.Contains(slideArmsOptions(j)) Then
CMB_DrawerSlideArmOptions = slideArmsOptions(j)
End If
Next
End If
Next
So do its the correct way to do it?
Thank!
-
May 17th, 2021, 11:45 AM
#2
Re: Nested loop on mutiple combo box
If you want to check if what has been entered in the TextBox is in an Array then just the the array "contains" property. You seem to be doing it backwards.
Code:
If handleOptions.Contains(TXB_CODE_ING.Text) Then
No need for a Loop.
-
May 17th, 2021, 11:48 AM
#3
Thread Starter
Junior Member
Re: Nested loop on mutiple combo box
Yes it look like it , Thank you
-
May 17th, 2021, 01:05 PM
#4
Thread Starter
Junior Member
Re: Nested loop on mutiple combo box
I got a message , 'Contains' is not a member of 'System.Array'. ??
-
May 17th, 2021, 02:05 PM
#5
Re: Nested loop on mutiple combo box
if Array.IndexOf(handleOptions, TXB_CODE_ING.Text) > -1
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 17th, 2021, 02:11 PM
#6
Re: Nested loop on mutiple combo box
Do you have the System.Linq namespace imported? It should be imported by default unless you're using a version of Visual Studio that is relatively old.
-
May 17th, 2021, 02:25 PM
#7
Thread Starter
Junior Member
Re: Nested loop on mutiple combo box
Originally Posted by dday9
Do you have the System.Linq namespace imported? It should be imported by default unless you're using a version of Visual Studio that is relatively old.
It look like it fixed my problem, Thank you!
-
May 17th, 2021, 02:28 PM
#8
Thread Starter
Junior Member
Re: Nested loop on mutiple combo box
Originally Posted by .paul.
if Array.IndexOf(handleOptions, TXB_CODE_ING.Text) > -1
My problem was fixed by imported System.Linq, but with your method, how I will copy the value to my combo box?
Thank a lot!
-
May 17th, 2021, 03:28 PM
#9
Re: Nested loop on mutiple combo box
Code:
ComboBox1.SelectedIndex = ComboBox1.FindStringExact(TXB_CODE_ING.Text)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
May 17th, 2021, 03:30 PM
#10
Thread Starter
Junior Member
Re: Nested loop on mutiple combo box
Originally Posted by .paul.
Code:
ComboBox1.SelectedIndex = ComboBox1.FindStringExact(TXB_CODE_ING.Text)
Perfect Thank a lot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|