excel vba - Three state value in vba -


i have global variable in excel vba named "state" can equal "high", "low" or "medium". every time want call variable, have make check loop (using select case or if) avoid having "state" equals other values:

select case state case = "high" 'code case = "low" 'code case = "medium" 'code case else 'error function end select 

i wonder if there more sophisticated method make variable more generic? want create 3 state type (like type boolean) can used other functions

you can use enum. example, define @ top of module:

enum state     high = 1     medium = 2     low = 3 end enum 

and can make use of it, example, this:

sub test(testval state)     select case testval         case high             msgbox "high!!"         case medium             msgbox "medium!"         case low             msgbox "low."     end select end sub 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -