473,729 Members | 2,197 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select Case statement with multiple varaibles

Hi All,

I wanted to know whether this is possible to use multiple variables to
use in the select case statement such as follows:

select case dWarrExpDateMon th, dRetailDateMont h
case "01" : dWarrExpDateMon th="Jan" : dRetailDateMont h="Jan"
case "02" : dWarrExpDateMon th="Feb" : dRetailDateMont h="Feb"
End Select

The reason is I have several date varaibles (mmddyy format) and I want
to display the months in word such as above. Right now I have repeated
the same select case statement for different variables. I was wondering
how can I avoid repeating the select case statement for different
variables which will be nothing but different months.

Thanks a million in advance.
Best regards,
mamun

Dec 11 '06 #1
1 21685

"microsoft.publ ic.dotnet.langu ages.vb" <ma******@hotma il.comwrote in
message news:11******** **************@ 80g2000cwy.goog legroups.com...
Hi All,

I wanted to know whether this is possible to use multiple variables to
use in the select case statement such as follows:

select case dWarrExpDateMon th, dRetailDateMont h
case "01" : dWarrExpDateMon th="Jan" : dRetailDateMont h="Jan"
case "02" : dWarrExpDateMon th="Feb" : dRetailDateMont h="Feb"
End Select

The reason is I have several date varaibles (mmddyy format) and I want
to display the months in word such as above. Right now I have repeated
the same select case statement for different variables. I was wondering
how can I avoid repeating the select case statement for different
variables which will be nothing but different months.

Thanks a million in advance.
Best regards,
mamun
I think you're quite confused as to the Select Case syntax. You should RTM
here:-

http://msdn.microsoft.com/library/en...71eefb3b01.asp
In all VB dialects a new line delimits one statement from another. The
colon : is also such a delimiter allow mulitple statements to appear on one
line. A common use of : in VB is in a Case statement:-

Select Case testExpression
Case expression : somevar = "some literal"
Case expression : somevar = "some other literal"
End Select

but this is just short hand for:-

Select Case testExpression
Case expression
somevar = "some literal"
Case expression
somevar = "some other literal"
End Select

Any case block can contain any number of statements which are only executed
if it's expression it the first one in the list of expressions to match the
testExpression.

Hence this is possilbe:-
Select case dWarrExpDateMon th
Case "01" : dWarrExpDateMon th="Jan" : dRetailDateMont h="Jan"
Case "02" : dWarrExpDateMon th="Feb" : dRetailDateMont h="Feb"
End Select

However note that you can only have one test expression.

At guess though I think you may have expected that dWarrExpDateMon th and
dRetailDateMont h to contain differerent values yet be resolved to their
appropriate abbreviation.

In that case a Function is a more appropriate solution:-

Function CvtToMonthAbbrv (rsIn)
Select Case rsIn
Case "01" : CvtToMonthAbbrv ="Jan"
Case "02" : CvtToMonthAbbrv ="Feb"
End Select
End Function

dWarrExpDateMon th = CvtToMonthAbbrv (dWarrExpDateMo nth )
dRetailDateMont h= CvtToMonthAbbrv (dRetailDateMon th)

Having said all that (for the purpose of education) the true solution to
your problem is that VBScript already has such a function built in :-

dWarrExpDateMon th = MonthName(CInt( dWarrExpDateMon th), True)
dRetailDateMont h= MonthName(CInt( dRetailDateMont h), True)

http://msdn.microsoft.com/library/en...63a9bdb241.asp
Anthony.

Dec 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6261
by: Ralph Freshour | last post by:
I have a question about the following PHP script - I got it off a web site tutorial on how to count users logged into your site - my question is the $PHP_SELF variable - it writes the name of the web page to the 'file' field in the table - I don't understand why it is doing that - I mean, isn't the SELECT DISTINCT statement only pulling those records from that one web page? I guess I just don't follow what it is doing with that SELECT...
2
20533
by: Omavlana | last post by:
Hi, I want to create a temporary table and store the logdetails from a.logdetail column. select a.logdetail , b.shmacno case when b.shmacno is null then select cast(substring(a.logdetail,1,charindex('·',a.logdetail)-1) as char(2)) as ShmCoy,
1
11112
by: avinash | last post by:
hi myself avi i am developing one appliacaion in which i am using vb 6 as front end, adodb as database library and sql sever 7 as backend. i want to update one table for which i required data from other table. and iretrive data from second table by giving some condition. when i get data, then to update first table i need to use do while loop. instead of that i want to use select statement directly in update query. plz give me some help....
17
5023
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by cust_no, ded_type_cd, chk_no)
15
2739
by: grunar | last post by:
After some thought on what I need in a Python ORM (multiple primary keys, complex joins, case statements etc.), and after having built these libraries for other un-named languages, I decided to start at the bottom. What seems to plague many ORM systems is the syntactic confusion and string-manipulation required to build the SQL Statements. If you want to do a Left Outer Join, support nested functions, and a nested conditional clause, you'd...
4
2274
by: Ian Richardson | last post by:
Hi, The function I've put together below is a rough idea to extend a SELECT list, starting from: <body> <form name="bambam"> <select id="fred"> <option value="1">1</option> <option value="2">2</option>
3
2319
by: atrottier | last post by:
I'am new here so I'd like to say hello and this seems to be a great site it has already helped me a few times. I just got an assignment to correct and modify a simple access application. First some background info:. I added a delete button on a subform to remove an item from that forms list. The subfrom is populated from a table that has a primary key composed of two number fields. I have assigned varaibles to the column values for the selected...
6
3506
by: dbuchanan | last post by:
There are three parts to this 1.) How do I cascade menus? 2.) And, how do I cascade menus with a multi-select CheckBoxList?
3
12629
by: CEO123 | last post by:
Does anyone know if it is possible and the syntax to test mutlitple expressions in a select case statement? This is the best I could come up with but it doesn't appear to be working Example: Select Case rng1.value And rng2.value Case rng1.value = 1 & rng2.value = 2 'code here
0
9428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9203
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9151
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6025
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.