You've got quite a few problems here. You're dimensioning dStateID as an integer, and then assigning a string value to it. That will give you an error every time. Plus, the dStateid variable is local to the initialization procedure, which means it will never be seen by the rest of the program.
Also, you're combining a case statement with an if-else, which is counter productive and confusing. Just make each decision a case. Look up the help on select case to get the syntax right, since using "select case true" makes no sense at all.