473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

multiple ifs converted to case statement in vb function

have code below:

Function ClassColl(strClass As Variant, strColl As Variant) As String

' Comments :
' Parameters : strClass
' strColl
' Returns : String Description
' Created : 2-5-2004 - Mark Mullins
' Modified :
'
' --------------------------------------------------------

On Error GoTo PROC_ERR

'declare variables
Dim class As String
Dim coll As String

class = UCase(CStr(strClass))
coll = UCase(CStr(strColl))

' 1-4 Family Residential

' Investement Real Estate
If class = "1A" And (coll = "83" Or coll = "84") Then
ClassColl = "1-4 Family Residential*Construction!Investment
RE"
ElseIf class = "C1" And (coll = "83" Or coll = "84" Or coll =
"90") Then
ClassColl = "1-4 Family Residential*Non
Construction!Investment RE"
ElseIf class = "C2" And (coll = "83" Or coll = "84" Or coll =
"90") Then
ClassColl = "1-4 Family Residential*Non
Construction!Investment RE"
ElseIf class = "C3" And (coll = "83" Or coll = "84" Or coll =
"90") Then
ClassColl = "1-4 Family Residential*Non
Construction!Investment RE"

I would like to convert this to a select case statement as there are
many more comparisons to do... can someone explain the use of a case
statement in this scenario... that is, if statement with an and
clause?

Thanks!

Mark Mullins
Union Planters
ma**********@upbna.com
Nov 12 '05 #1
2 3801
rkc

"Mark Mullins" <ma**********@upbna.com> wrote in message
news:6b**************************@posting.google.c om...
have code below:

Function ClassColl(strClass As Variant, strColl As Variant) As String

' Comments :
' Parameters : strClass
' strColl
' Returns : String Description
' Created : 2-5-2004 - Mark Mullins
' Modified :
'
' --------------------------------------------------------


Do you really want to maintain all that information in your source code?
Why not use the power of SQL and your database?


Nov 12 '05 #2
On 9 Feb 2004 08:56:48 -0800, Mark Mullins wrote:
have code below:

Function ClassColl(strClass As Variant, strColl As Variant) As String

' Comments :
' Parameters : strClass
' strColl
' Returns : String Description
' Created : 2-5-2004 - Mark Mullins
' Modified :
'
' --------------------------------------------------------

On Error GoTo PROC_ERR

'declare variables
Dim class As String
Dim coll As String

class = UCase(CStr(strClass))
coll = UCase(CStr(strColl))

' 1-4 Family Residential

' Investement Real Estate
If class = "1A" And (coll = "83" Or coll = "84") Then
ClassColl = "1-4 Family Residential*Construction!Investment
RE"
ElseIf class = "C1" And (coll = "83" Or coll = "84" Or coll =
"90") Then
ClassColl = "1-4 Family Residential*Non
Construction!Investment RE"
ElseIf class = "C2" And (coll = "83" Or coll = "84" Or coll =
"90") Then
ClassColl = "1-4 Family Residential*Non
Construction!Investment RE"
ElseIf class = "C3" And (coll = "83" Or coll = "84" Or coll =
"90") Then
ClassColl = "1-4 Family Residential*Non
Construction!Investment RE"

I would like to convert this to a select case statement as there are
many more comparisons to do... can someone explain the use of a case
statement in this scenario... that is, if statement with an and
clause?

Thanks!

Mark Mullins
Union Planters
ma**********@upbna.com


Few notes:
- If your arguments are to be strings (you have use the common name
convention for string) then declare them as strings. Variants use up far
more resources.
- I would have thought "Class" was a reserved word. You may come into
problems with this. Use a better var name.
- I don't think enough info about all the possible choices are here to help
with the exact structure. So far, only "1A" can have be a "1-4 Family
Residential*Construction!Investment RE" and all others having 83,84 or 90
are the same, so that makes the cases very short. But this should be a good
enough guidline.

Function ClassColl(strClass As String, strColl As String) As String

' Comments :
' Parameters : strClass
' strColl
' Returns : String Description
' Created : 2-5-2004 - Mark Mullins
' Modified :
'
' --------------------------------------------------------

On Error GoTo PROC_ERR

strClass = UCase(strClass)
strColl = UCase(strColl)

' 1-4 Family Residential

' Investement Real Estate
Select Case strColl
Case "83", "84"
Select Case strClass
Case "1A"
ClassColl = "1-4 Family Residential*Construction!Investment RE"
Case Else
ClassColl = "1-4 Family Residential*NonConstruction!Investment RE"
End Select
Case "90"
ClassColl = "1-4 Family Residential*NonConstruction!Investment RE"
End Select
--
Mike Storr
veraccess.com
Nov 12 '05 #3

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

Similar topics

4
by: Angelos | last post by:
Ok... I have to make this administation area where I have multiple Contents to add edit delete publish . The problem is that I don't know what is the best way of making the forms. At the moment I...
10
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it...
8
by: Sans Spam | last post by:
Greetings! I have a table that contains all of the function permissions within a given application. These functions are different sections of a site and each has its own permissions (READ, WRITE,...
4
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email...
7
by: Glenn Davy | last post by:
Hidely hodley everyone I'd like to run a series of of sql ddl statements against an msde2000 server. Normally I just deploy cmd file that impliments as osql statement, but I'd like to store the...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
8
by: Les Coover | last post by:
I have tried writing the selection process after scanf many different ways. No matter what is selected program execution goes to the add_data function. How can I get this to work? /*...
1
by: microsoft.public.dotnet.languages.vb | last post by:
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 dWarrExpDateMonth, dRetailDateMonth case...
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.