ComboBox策略的功能

时间:2015-06-25 14:03:47

标签: methods combobox redundancy

我有四个组合框,一切都如下:

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

类似地,其他两个组合框具有相同的身体

我想通过方法调用替换此代码块,并在方法体中实现select子句体,并在需要时调用它。

请给我一个解决方案

1 个答案:

答案 0 :(得分:0)

创建一个方法,将输入作为组合框选择的索引,即整数 现在在方法中写如下:

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

在必要时致电method1