"Bob" <co*******@hotmail.com> wrote in message
news:2c*************************@posting.google.co m...
thank you but i was just wondering, how does case select work and where is
it
used. i haven't programmed in a while and i m trying to re-learn
everything
thanky you
Any time you want one action (KeyDown, MouseDown,) or sub to do more than
one thing depending on the value of a variable (MouseX, KeyCode) (or any
other variable), there are two ways to do it.
One is to create a list of if,then,else statements with your code inside
each one. That's asking for slower code and more likelihood for error. The
other is to use a select case arrangement. In that, you simply type select
case (required argument) where the required argument is shown in the
procedure (take a look at Form_KeyDown and notice that it is followed by
KeyCode as one of the required arguments)
then simply type case (what the required argument is) and follow it with the
code you want to execute. When you are all finished with the different
cases, type end select and you're done.
so you could, in the KeyDown example have the following:
if keycode=something then
do things
end if
if keycode=something else then
do other things
end if
or you could have
select case keycode
case vbkeyescape
do something
case vbkeya
do something else
end select
See? You should be able to find out more in the Visual Basic help, or with
the purchase of almost any book on Visual Basic.