日期:2014-05-17  浏览次数:20732 次

if or case 哪个好?
有一种效果,有两种实现方法,哪个效率高?
如:
sub   sel(str)
select   case   str
case   a
...
case   b
...
case   c
...
end   select
end   sub
'-------------
在需要的地方调用
for   i=1   to   50
sel(i)
next

方法二
for   i=1   to   50
if   str= " "   then   ...
或者是   if   str=**   then   ..

next

请高手指教!



------解决方案--------------------
这个时候当然是方法二了

条件多于2个的话,才可以考虑用Select Case
------解决方案--------------------
条件多时,用Select Case比较好。一来流程比较清晰,二来,据说性能比较好。