473,657 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select Case in a Loop

10 New Member
I want to use select case in a loop as under:
Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = 1
  3. While i < 6
  4.     Select Case Field1
  5.         Case "Title"
  6.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  7.         Case "Author"
  8.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  9.         Case "Subject"
  10.             strFld(i) = "Subject"
  11.         Case "Publisher"
  12.             strFld(i) = "Publisher"
  13.         Case "Year of Publication"
  14.             strFld(i) = "Year"
  15.         Case "Call No"
  16.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  17.         Case "Acc No"
  18.             strFld(i) = "ACCNO"
  19.     End Select
  20.     i = i + 1
  21. Wend
  22.  
  23.  
can I use the line no 4 code as:
Select Case Field1, Field2, Field3, Field4, Field5

Note: Field(5) is string variable and strFld(5) is also a string variable
Sep 12 '07 #1
4 5681
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = 1
  3. While i < 6
  4.     Select Case "Field" & i
  5.         Case "Title"
  6.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  7.         Case "Author"
  8.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  9.         Case "Subject"
  10.             strFld(i) = "Subject"
  11.         Case "Publisher"
  12.             strFld(i) = "Publisher"
  13.         Case "Year of Publication"
  14.             strFld(i) = "Year"
  15.         Case "Call No"
  16.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  17.         Case "Acc No"
  18.             strFld(i) = "ACCNO"
  19.     End Select
  20.     i = i + 1
  21. Wend
  22.  
  23.  
Sep 12 '07 #2
ataurrehman
10 New Member
Dear
Thanks for response.
"Select Case "Field" & i" is treated as:
Select "Field1", "Field2".

But i want to use it as variable, not constant. Field1, Field2... are the names of combo boxes on the form.
Values of these combo boxes may differ in all cases

Ata

Try this ...

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. i = 1
  3. While i < 6
  4.     Select Case "Field" & i
  5.         Case "Title"
  6.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  7.         Case "Author"
  8.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  9.         Case "Subject"
  10.             strFld(i) = "Subject"
  11.         Case "Publisher"
  12.             strFld(i) = "Publisher"
  13.         Case "Year of Publication"
  14.             strFld(i) = "Year"
  15.         Case "Call No"
  16.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  17.         Case "Acc No"
  18.             strFld(i) = "ACCNO"
  19.     End Select
  20.     i = i + 1
  21. Wend
  22.  
  23.  
Sep 14 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Dear
Thanks for response.
"Select Case "Field" & i" is treated as:
Select "Field1", "Field2".

But i want to use it as variable, not constant. Field1, Field2... are the names of combo boxes on the form.
Values of these combo boxes may differ in all cases

Ata
Ata

I'm totally confused.

Can you explain logically (not with code) exactly what you are trying to do.
Sep 14 '07 #4
ataurrehman
10 New Member
Dear mmccarthy

Thanks for response. Sorry I could not make clear question. But the problem has been solved as under with a slight change:
I hope you may easily understand the following code:

Expand|Select|Wrap|Line Numbers
  1. Dim i As Integer
  2. Dim cb(5) As ComboBox
  3. Set cb(1) = Field1
  4. Set cb(2) = Field2
  5. Set cb(3) = Field3
  6. Set cb(4) = Field4
  7. Set cb(5) = Field5
  8.  
  9. i = 1
  10. While i < 6
  11.     Select Case cb(i)
  12.         Case "Title"
  13.             strFld(i) = "([Title] & ': ' & [Subtitle])"
  14.         Case "Author"
  15.             strFld(i) = "([AUTHOR] & ', ' & [SUBAUTHOR])"
  16.         Case "Subject"
  17.             strFld(i) = "Subject"
  18.         Case "Publisher"
  19.             strFld(i) = "Publisher"
  20.         Case "Year of Publication"
  21.             strFld(i) = "Year"
  22.         Case "Call No"
  23.             strFld(i) = "([DDC_NO] & ' ' & [Auth_MARK])"
  24.         Case "Acc No"
  25.             strFld(i) = "ACCNO"
  26.     End Select
  27.     i = i + 1
  28. Wend
  29.  
  30.  
Ata

I'm totally confused.

Can you explain logically (not with code) exactly what you are trying to do.
Sep 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
5189
by: Mohammed Mazid | last post by:
Hi folks! Can anyone please help me with this? I am developing a Quiz program but I am stuck with "multiple answers". Basically I need some sort of code that would select multiple answers using check boxes. For example, a question such as
4
4076
by: Ed L. | last post by:
I think I'm seeing table-level lock contention in the following function when I have many different concurrent callers, each with mutually distinct values for $1. Is there a way to reimplement this function using select-for-update (or equivalent) in order to get a row-level lock (and thus less contention) while maintaining the function interface? The docs seem to suggest so, but it's not clear how to return the SETOF queued_item and also...
6
28719
by: mabond | last post by:
Hi Is it possible to compare a vaule for a select case statement using a wildcard. e.g. somthing like Select case myValue case like "*ing" end select
4
2266
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>
22
12463
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient moConn.Mode = adModeReadWrite' or using default...same result
16
2740
by: Richard Maher | last post by:
Hi, I have this Applet-hosted Socket connection to my server and in an ONevent/function I am retrieving all these lovely rows from the server and inserting them into the Select-List. (The on screen appearance of the Select List grows for the first 5 rows then the scroll bar appears if there's more). So far so good. . . The problem is that none of the rows I'm inserting appear on the screen until I have RETURNed from my function; so If...
10
1951
by: Michele Simionato | last post by:
I have always been curious about how people implement mainloops (or, in Twisted terminology, reactors). So I sit down and I wrote the following simple implementation: import itertools class SimpleReactor(object): DELAY = 0.001 # seconds
1
2354
amitpatel66
by: amitpatel66 | last post by:
Hi, Is PLSQL Anonymous block allowed in CASE WHEN statement when CASE is used in SELECT statement. Check below code which executes but does not return anything: SELECT job, CASE WHEN job = 'TL' THEN DECLARE CURSOR C1 IS SELECT ename FROM emp WHERE job = 'TL'; concat_str VARCHAR2(2000) := NULL;
4
10662
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie in php and I got error in my index.php which is: 1054 - Unknown column 'p.products_id' in 'on clause' select p.products_image, pd.products_name, p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from products_description pd,...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
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...
0
8726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
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
8603
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...
0
5632
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
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.