ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 13th, 2003, 04:05 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 5
Question Case statements

Having trouble understanding how case statements actually work. I've read that if you've got too many if/else statements then you should really use case statements.

But how do you actually write the statement for something like this:

Code:
dim strDelete
if Request.form("delPcode") <> "" then
	table = "<b>Products</b>"
	strDelete = Request.form("delPcode")
	delSQL = "DELETE FROM products WHERE id IN (" & strDelete & ")"
else if Request.form("delAuth") <> "" then
	table = "<b>Authors</b>"
	strDelete = Request.form("delAuth")
	delSQL = "DELETE FROM authors WHERE authorID IN (" & strDelete & ")"
else if Request.form("delSupp") <> "" then
	table = "<b>Suppliers</b>"
	strDelete = Request.form("delSupp")
	delSQL = "DELETE FROM suppliers WHERE ID IN (" & strDelete & ")"
	
end if
end if
end if

Reply With Quote
  #2  
Old November 14th, 2003, 02:50 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,843 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 22 h 48 m 43 sec
Reputation Power: 766
You can't use a select .. case in your example. There can only be one tested expression and it's only evaluated once. An simple example of select case:
Code:
<%
myStr = "b"
Select Case UCase(myStr)
  Case "A"
    'some code here if it was an A
  Case "B"
    response.write "Yep, it was a ""B"""
  Case Else
    'code in case nothing else matches
End Select
%>

Reply With Quote
  #3  
Old November 14th, 2003, 04:40 PM
xtremcoder xtremcoder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Houston, TX
Posts: 131 xtremcoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 36 m 52 sec
Reputation Power: 6
Send a message via AIM to xtremcoder Send a message via Yahoo to xtremcoder
you cant use a select statement because you are comparing differect variables... like Doug said, with a select stmt you have to compare the SAME variable...

Reply With Quote
  #4  
Old November 16th, 2003, 03:18 PM
Tyssen Tyssen is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Brisbane
Posts: 129 Tyssen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 31 m 55 sec
Reputation Power: 5
Oh, OK. So the only way to code more complex conditional statements like that is to have lots of ifs and end ifs?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Case statements


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway