473,422 Members | 2,149 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,422 software developers and data experts.

the switch statement has got me a little confused..can someone clear this up for me please

extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742, 1)

I look at this and say ok
if race = black and sex = female then extracalc = 1.952
if race = black then extracalc = 1.21
if sex = female then extracalc = .742

else

extracalc = 1
but of course this gives an error because to work it has to have
another value
such as 999

extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742,999, 1)

what does the 999 place represent?

if all test are false then it would be null would it not?

not sure what I am missing here but can someone explain what the
places for 999 and 1 repesent

it just looks like it has one more value than it needs
thanks big time

Jerry
Dec 7 '05 #1
6 1529
As you said, if all tests are false, the switch function returns null.
Therefore, it doesn't take an extra "else" value at the end. It only takes
pairs of (test), (value if true).
"sparks" <js******@swbell.net> wrote in message
news:kn********************************@4ax.com...
extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742, 1)

I look at this and say ok
if race = black and sex = female then extracalc = 1.952
if race = black then extracalc = 1.21
if sex = female then extracalc = .742

else

extracalc = 1
but of course this gives an error because to work it has to have
another value
such as 999

extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742,999, 1)

what does the 999 place represent?

if all test are false then it would be null would it not?

not sure what I am missing here but can someone explain what the
places for 999 and 1 repesent

it just looks like it has one more value than it needs
thanks big time

Jerry

Dec 7 '05 #2
thats what I thought but it doesn't work.
the first statement will give you an error until you add something
like the 999 I did in the second statement.

I can't understand what it expects to see and why.
it like
else 999
else 1
or something like that
Jerry

On Wed, 7 Dec 2005 09:43:31 -0800, "John Welch"
<j+ohnw+elch@cal+central.com (remove +'s)> wrote:
As you said, if all tests are false, the switch function returns null.
Therefore, it doesn't take an extra "else" value at the end. It only takes
pairs of (test), (value if true).
"sparks" <js******@swbell.net> wrote in message
news:kn********************************@4ax.com.. .
extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742, 1)

I look at this and say ok
if race = black and sex = female then extracalc = 1.952
if race = black then extracalc = 1.21
if sex = female then extracalc = .742

else

extracalc = 1
but of course this gives an error because to work it has to have
another value
such as 999

extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742,999, 1)

what does the 999 place represent?

if all test are false then it would be null would it not?

not sure what I am missing here but can someone explain what the
places for 999 and 1 repesent

it just looks like it has one more value than it needs
thanks big time

Jerry


Dec 7 '05 #3
It is thinking that your 999 and 1 are just another pair like "black = -1,
1.21". Take out both the 999 and the 1, so that you just have the three
pairs.

"sparks" <js******@swbell.net> wrote in message
news:oj********************************@4ax.com...
thats what I thought but it doesn't work.
the first statement will give you an error until you add something
like the 999 I did in the second statement.

I can't understand what it expects to see and why.
it like
else 999
else 1
or something like that
Jerry

On Wed, 7 Dec 2005 09:43:31 -0800, "John Welch"
<j+ohnw+elch@cal+central.com (remove +'s)> wrote:
As you said, if all tests are false, the switch function returns null.
Therefore, it doesn't take an extra "else" value at the end. It only takes
pairs of (test), (value if true).
"sparks" <js******@swbell.net> wrote in message
news:kn********************************@4ax.com. ..
extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742, 1)

I look at this and say ok
if race = black and sex = female then extracalc = 1.952
if race = black then extracalc = 1.21
if sex = female then extracalc = .742

else

extracalc = 1
but of course this gives an error because to work it has to have
another value
such as 999

extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742,999, 1)

what does the 999 place represent?

if all test are false then it would be null would it not?

not sure what I am missing here but can someone explain what the
places for 999 and 1 repesent

it just looks like it has one more value than it needs
thanks big time

Jerry

Dec 7 '05 #4
well if you do that you have no else for the other 16 combos that are
not these three...they are all = 1.

On Wed, 7 Dec 2005 10:27:13 -0800, "John Welch"
<j+ohnw+elch@cal+central.com (remove +'s)> wrote:
It is thinking that your 999 and 1 are just another pair like "black = -1,
1.21". Take out both the 999 and the 1, so that you just have the three
pairs.

"sparks" <js******@swbell.net> wrote in message
news:oj********************************@4ax.com.. .
thats what I thought but it doesn't work.
the first statement will give you an error until you add something
like the 999 I did in the second statement.

I can't understand what it expects to see and why.
it like
else 999
else 1
or something like that
Jerry

On Wed, 7 Dec 2005 09:43:31 -0800, "John Welch"
<j+ohnw+elch@cal+central.com (remove +'s)> wrote:
As you said, if all tests are false, the switch function returns null.
Therefore, it doesn't take an extra "else" value at the end. It only takes
pairs of (test), (value if true).
"sparks" <js******@swbell.net> wrote in message
news:kn********************************@4ax.com ...
extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742, 1)

I look at this and say ok
if race = black and sex = female then extracalc = 1.952
if race = black then extracalc = 1.21
if sex = female then extracalc = .742

else

extracalc = 1
but of course this gives an error because to work it has to have
another value
such as 999

extracalc = Switch(Me.Parent.Race_Black = -1 And Me.Parent.Sex =
"Female", 1.952, Me.Parent.Race_Black = -1, 1.21, Me.Parent.Sex =
"Female", 0.742,999, 1)

what does the 999 place represent?

if all test are false then it would be null would it not?

not sure what I am missing here but can someone explain what the
places for 999 and 1 repesent

it just looks like it has one more value than it needs
thanks big time

Jerry


Dec 7 '05 #5
You can use 999,1 if you want and it will give you an 'else' of 1, because
999 will evaluate to "true" and so the switch will get a value of 1.
It would be more clear to say it more directly, like: black = -1,1.2,
sex='female', 1.3, true, 1
"sparks" <js******@swbell.net> wrote in message
news:sq********************************@4ax.com...
well if you do that you have no else for the other 16 combos that are
not these three...they are all = 1.

On Wed, 7 Dec 2005 10:27:13 -0800, "John Welch"
<j+ohnw+elch@cal+central.com (remove +'s)> wrote:
It is thinking that your 999 and 1 are just another pair like "black = -1,
1.21". Take out both the 999 and the 1, so that you just have the three
pairs.

"sparks" <js******@swbell.net> wrote in message
news:oj********************************@4ax.com. ..
thats what I thought but it doesn't work.
the first statement will give you an error until you add something
like the 999 I did in the second statement.

I can't understand what it expects to see and why.
it like
else 999
else 1
or something like that

Dec 7 '05 #6
thanks that clears that up.
it was the 999 that was throwing me
Jerry

On Wed, 7 Dec 2005 12:31:29 -0800, "John Welch"
<j+ohnw+elch@cal+central.com (remove +'s)> wrote:
You can use 999,1 if you want and it will give you an 'else' of 1, because
999 will evaluate to "true" and so the switch will get a value of 1.
It would be more clear to say it more directly, like: black = -1,1.2,
sex='female', 1.3, true, 1
"sparks" <js******@swbell.net> wrote in message
news:sq********************************@4ax.com.. .
well if you do that you have no else for the other 16 combos that are
not these three...they are all = 1.

On Wed, 7 Dec 2005 10:27:13 -0800, "John Welch"
<j+ohnw+elch@cal+central.com (remove +'s)> wrote:
It is thinking that your 999 and 1 are just another pair like "black = -1,
1.21". Take out both the 999 and the 1, so that you just have the three
pairs.

"sparks" <js******@swbell.net> wrote in message
news:oj********************************@4ax.com ...
thats what I thought but it doesn't work.
the first statement will give you an error until you add something
like the 999 I did in the second statement.

I can't understand what it expects to see and why.
it like
else 999
else 1
or something like that


Dec 8 '05 #7

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

Similar topics

17
by: prafulla | last post by:
Hi all, I don't have a copy of C standard at hand and so anyone of you can help me. I have always wondered how switch statements are so efficient in jumping to the right case (if any)? Can...
13
by: Adam Blair | last post by:
Is it possible to bind a switch statement to an Enum such that a compile-time error is raised if not all values within the Enum are handled in the switch statement? I realise you can use default:...
15
by: Benny Raymond | last post by:
I'm confused as to how fallthrough is limited in switch. For example the following works: string switch_test = "a"; switch (switch_test) { case "a": case "b": case "c": doSomething(a);
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
14
by: serrand | last post by:
Could someone tell me a beautiful way to exit from a switch and a loop in one statement ... without using a goto... and if possible without using an auxiliary variable as i did... int res;...
9
by: Raj | last post by:
public static void HandleException(ref Exception io_exException, bool i_blnPropagateException) { switch (true) { case io_exException is ApplicationHandledException: { if...
22
by: John | last post by:
Hi Folks, I'm experimenting a little with creating a custom CEdit control so that I can decide on what the user is allowed to type into the control. I started off only allowing floating point...
2
osward
by: osward | last post by:
Hello there, I am using phpnuke 8.0 to build my website, knowing little on php programing. I am assembling a module for my member which is basically cut and paste existing code section of...
9
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
1
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...
0
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...
0
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...

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.