Reputation: 829
This little piece of code is supposed to fire off and give me the correct variable but no matter what is in the variable "numericDay", the Variable "suffix" gives me "th". i don't see why it wouldn't change when the value of "numericDay changes both are string variables.
Select Case numericDay
Case numericDay = "1" Or "21" Or "31"
suffix = "st"
Case numericDay = "2" Or "22"
suffix = "nd"
Case numericDay = "3" Or "23"
suffix = "rd"
Case Else
suffix = "th"
End Select
Upvotes: 13
Views: 115480
Reputation: 11
i think this is the correct logic...
Select Case Right(Text1.Text, 1)
Case "1"
Label3.Caption = "st"
Case "2"
Label3.Caption = "nd"
Case "3"
Label3.Caption = "rd"
Case ""
Label3.Caption = ""
Case Else
Label3.Caption = "th"
End Select
Upvotes: 1
Reputation: 15560
You've written your select incorrectly. Try the following
Eg: display day according to the number which is entered.
public function day_display(day as Integer) as String
select case day
case 1: day_display = "Sunday"
case 2: day_display = "Monday"
case 3: day_display = "Tuesday"
case 4: day_display = "Wednesday"
case 5: day_display = "Thursday"
case 6: day_display = "Friday"
case 7: day_display = "Saturday"
case else: day_display = "Wrong entry."
end select
end function
day_display(1) will return "Sunday"
Upvotes: 0
Reputation: 2534
"2" Or "22"
will do a bytewise or with 2 and 22, which corresponds to 22.
Upvotes: 5
Reputation: 705
According to the msdn you should have written it like this:
Select Case numericDay
Case "1", "21", "31"
suffix = "st"
Case "2", "22"
suffix = "nd"
Case "3", "23"
suffix = "rd"
Case Else
suffix = "th"
End Select
Upvotes: 8
Reputation: 4841
You've written your select incorrectly. Try the following:
Select Case numericDay
Case "1", "21", "31"
suffix = "st"
Case "2", "22"
suffix = "nd"
Case "3", "23"
suffix = "rd"
Case Else
suffix = "th"
End Select
For future reference: http://www.vb6.us/tutorials/learn-if-else-and-select-statements-vb6
Upvotes: 38