excel - Setting numeric constraints on variables -
is there way put constraints when creating variables in vba?
example: dim alfa integer
now i'd excel accept only values 0 99, how can that?
many thanks
you validate this:
sub test() dim integer = 100 if not (i >= 0 , <= 99) err.raise number:=6, description:="number not valid" 'continue use end sub
you create new class, accept values. in cases overkill, here is:
put standard module
sub test() dim specialnumber snumber set specialnumber = new snumber specialnumber.value = 1 specialnumber.value = 100 'this line throw error end sub
then put class module , name module snumber
private specialnumber integer public property value() integer value = specialnumber end property public property let value(v integer) if not (v >= 0 , v <= 99) err.raise number:=6, description:="number not valid" else specialnumber = v end if end property
Comments
Post a Comment