By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Select... Case Array Question

P: n/a
Hi

If i am using a Select... Case is there any way to have the elements
of an array tested within a case, for example:

Dim MyChar as Char
Select Case MyChar
Case "a"c, "b"c, "c"c
'Do Something
End Select
Would something like this be possible:

Dim MyChar as Char
Dim testChars() as Char = {"a"c, "b"c, "c"c}
Select Case MyChar
CasetestChars
'Do Something
End Select

cheers

Blu

Nov 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"BluDog" <ne**@nospam.bludog.net> wrote in message
news:lv********************************@4ax.com...
Would something like this be possible:

Dim MyChar as Char
Dim testChars() as Char = {"a"c, "b"c, "c"c}
Select Case MyChar
CasetestChars
'Do Something
End Select

cheers

Blu


Nope. Whatever follows "Case" needs to be something the compiler can
resolve, i.e. a const, enum or literal value. A variable won't git it since
that is a runtime value. (there is probably a more technically correct way
to say that!)

Best Regards,

Andy
Nov 20 '05 #2

P: n/a
"Andy Becker" <x@x.com> wrote in message
news:O3**************@tk2msftngp13.phx.gbl...

Nope. Whatever follows "Case" needs to be something the compiler can
resolve, i.e. a const, enum or literal value. A variable won't git it since that is a runtime value. (there is probably a more technically correct way to say that!)


I tried this today but couldn't make it work:
(pseudo code, don't know if syntax is correct

Select Case Messagebox.Show("message",,DialogButtonsOKYesNo)
Case DialogButtonYes
code
Case DialogbuttonNo
code
End Case

Can anyone explain why that doesn't work?
Nov 20 '05 #3

P: n/a
Ricky,

I do not know why it is not working, this code works for me.

Select Case MessageBox.Show("messagebox", _
"", MessageBoxButtons.YesNo)
Case DialogResult.Yes
MessageBox.Show("Yes")
Case DialogResult.No
MessageBox.Show("No")
End Select

So I am curious why this works not for you?

Cor
Nov 20 '05 #4

P: n/a
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:OU**************@TK2MSFTNGP11.phx.gbl...
Ricky,

I do not know why it is not working, this code works for me.

Select Case MessageBox.Show("messagebox", _
"", MessageBoxButtons.YesNo)
Case DialogResult.Yes
MessageBox.Show("Yes")
Case DialogResult.No
MessageBox.Show("No")
End Select

So I am curious why this works not for you?


I'm not sure. I didn't fool with it long before just going with an If. I'll
try it again. Thanks.
Nov 20 '05 #5

P: n/a
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
Nope. Whatever follows "Case" needs to be something the compiler can
resolve, i.e. a const, enum or literal value. A variable won't git it since
that is a runtime value. (there is probably a more technically correct

way
to say that!)


I tried this today but couldn't make it work:
(pseudo code, don't know if syntax is correct

Select Case Messagebox.Show("message",,DialogButtonsOKYesNo)
Case DialogButtonYes


'DialogResult.Yes'.
code
Case DialogbuttonNo


'DialogResult.No'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 20 '05 #6

P: n/a
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...
* "Ricky W. Hunt" <rh*****@hotmail.com> scripsit:
Nope. Whatever follows "Case" needs to be something the compiler can
resolve, i.e. a const, enum or literal value. A variable won't git it

since
that is a runtime value. (there is probably a more technically correct

way
to say that!)


I tried this today but couldn't make it work:
(pseudo code, don't know if syntax is correct

Select Case Messagebox.Show("message",,DialogButtonsOKYesNo)
Case DialogButtonYes


'DialogResult.Yes'.


That's what I had. It was probably some other syntax problem. I was in a
hurry and needed to get it out. I'll try it again tonight. Thanks.
Nov 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.