ComboBox strategies to function

23 views Asked by At

I have four combo box everything does the same as follows:

Select Case combobox1.selectedItem
case 0 
str=str & "' AND"
case 1
str= str & "'"
end case

select case combobox2.selected item
 case 0 
str=str & "' AND"
case 1
str= str & "'"
end case

Similarly the other two comboboxes have the same body

I want to replace this code block by a method call and implement the select clause body in a method body and call it when required.

Please give me a solution

1

There are 1 answers

0
AudioBubble On BEST ANSWER

Create a method that takes the input as combobox selected index i.e an integer now in the method write as follows:

method1(int x)
{
Select Case x 
case 0 
str=str & "' AND"
case 1
str= str & "'"
end case
}

Call method1 where required.