Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if/then statement 1

Status
Not open for further replies.

micawber

Programmer
Dec 10, 2002
71
GB
I have the following if/then statement on my asp page, The problem i have is i need to add more instances to the highlighted word.
Can anyone advise?
Code:
If obj_RS1("FullTimeOccupation") = "CH" Then 
	If UCase(str_Value) <> [COLOR=red]"Chef"[/color] Then
		int_Errors = 1
		str_Error = "Use ""Chef"" as your occupation"
	End If
End If



 
First off, if you change the str_Value to uppercase, you would need to compare it to an upper case string, like:
Code:
If UCase(str_Value) <> "CHEF" Then

To include more choices, you could use multiple AND conditions:
Code:
If UCase(str_Value) <> "CHEF" And _
   UCase(str_Value) <> "COOK" Then
   int_Errors = 1
   str_Error = "Use ""Chef"" as your occupation"
End If

Or you can use SELECT CASE
Code:
Select Case UCase(str_Value)
   Case "CHEF"
   Case "COOK"
   Case Else
      int_Errors = 1
      str_Error = "Use ""Chef"" as your occupation"
End Select

 
Thanks guitarzan! Great help!
I have a function that lists the different instances, is it possible to use this rather than use the 'And _' or 'select'?


Code:
Function IsChefDesc( str_Desc )
	Select Case str_Desc
		Case "Chef", "Cook", "Pastry Chef", "Waiter", "Head Chef", "Kitchen Worker", "Bar Staff", "Bar Manager", "Barmaid", "Barman", "Assistant Cook"
			IsChefDesc = True

		Case Else
			IsChefDesc = False
	End Select
End Function
 
Yes you can use that, but this function is case-sensitive. Chef would return true, but chef or CHEF etc would return false.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top