|
 |
asp_web_howto thread: Select Case in a Sub Procedure
Message #1 by "Phillip Conrad" <phillip.conrad@f...> on Wed, 21 Nov 2001 21:26:22
|
|
I'm calling a the following Sub Procedure in my asp
++++
Sub getFrequency(strFreqCd)
Trim(strFreqCd)
Select Case Frequency
Case "q"
Response.Write "Quarter ending " & getMonth(Left(adoRSRpts(5).Value,
10))
Case "m"
Response.Write "Month of " & getMonth(Left(adoRSRpts(5).Value, 10))
Case Else
Response.Write Left(adoRSRpts(5).Value, 10)
End Select
End Sub
+++
I verified that "m" is a valid value however, I only get the result
from 'Case Else' in my page. Is something wrong in the way I coded my
procedure?
Thanks.
Message #2 by Imar Spaanjaars <Imar@S...> on Wed, 21 Nov 2001 22:32:50 +0100
|
|
Hi there,
It looks like there are two things wrong, and another situation might cause
problems as well.
First the Trim statement. You are not assigning it back to the value of
strFreqCd, so after the Trim command, the value is still the same.
Change it to this:
strFreqCd = Trim(strFreqCd)
Then you run a Case on the variable Frequency, which has not been defines.
So either run the Case on strFreqCd, or modify the line above to this:
Frequency = Trim(strFreqCd)
And then the Case statement: Case is case-sensitive (no pun intended), so
maybe you are passing a capital M instead of lower case m.
If case is not important, the safest way to handle a Case statement is like
this:
Select Case UCase(Frequency)
Case "Q"
Case "M"
etc etc
HtH
Imar
At 09:26 PM 11/21/2001 +0000, you wrote:
>I'm calling a the following Sub Procedure in my asp
>++++
>
>Sub getFrequency(strFreqCd)
>Trim(strFreqCd)
> Select Case Frequency
> Case "q"
> Response.Write "Quarter ending " & getMonth(Left(adoRSRpts(5).Value,
>10))
> Case "m"
> Response.Write "Month of " & getMonth(Left(adoRSRpts(5).Value, 10))
> Case Else
> Response.Write Left(adoRSRpts(5).Value, 10)
> End Select
>End Sub
>
>+++
>I verified that "m" is a valid value however, I only get the result
>from 'Case Else' in my page. Is something wrong in the way I coded my
>procedure?
>
>Thanks.
|
|
 |