On Aug 26, 2006, at 2:59 PM, Phil M wrote:

On Aug 26, 2006, at 2:43 PM, Terry Ford wrote:

Try this with an editfield and a pushbutton with this in the Action Code:

  Dim a As Integer
  a=val(EditField1.Text)

  Select Case a
  Case 1
    MsgBox str(a)
  Case Is = 2
    MsgBox str(a)
  Case Is>10,9
    MsgBox str(a)
  End Select

OK... what is wrong?

Absolutely nothing. Yet, this was just a simple example.

The message box will only display for values: 1, 2, 9 and values of 11 and greater. Everything seems logical to me.

"Case 1" is normal syntax.

"Case Is = 2" is strange but is the equivalent to "Case 2"

Basically that is what "Is" does.

"Case Is>10,9" is the only one which is more complex, but not when you consider the comma to separate conditions. You could write this as an if statement like this:

    If (a > 10) Or (a = 9) Then

True. The comma replaces the Or operator.

This particular case statement does not have an "Else" so there is no catch-all behavior for values which fall outside that range.

Also true, but that wasn't my purpose. The following is.

What follows is an undocumented feature made aware to me by Norman Palardy. Up until now, I was unaware that there were ways to use complex boolean evaluations within Select Case statements if the subject of evaluation was a boolean itself. It is not the normal usage of Select Case statements but it does work. Here's an example:

  Dim a As Integer

  a=val(EditField1.Text)

  Select Case True

  Case a=1
    MsgBox str(a)
  Case a= 2
    MsgBox str(a)
  Case a >10 Or a=9
    MsgBox str(a)
  End Select

  EditField1.Text="" // Clear EditField1

You can even use an And in this Boolean test case. What you *cannot* do is use "Case Is" with more than one simple comparison of non boolean comparisons.

Select Case has developed a lot but it would also be nice if Case Is could evaluate more than a single boolean comparison of integers, etc.

Just a thought. :)

Terry





_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to