Non-AppFrame Question


Author
Message
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Also, since I am new to VB.NET and coming from Clarion, is there a way to check a single field for specific values instead of a long IF statement or Select...Case?

Example in Clarion:

IF INLIST(MyField, "Male", "Female", "Both")
    MESSAGE("Valid")
ELSE
    MESSAGE("INVALID")
END

In Clarion I could test for multiple values with a single statement as shown above (I believe up to 25 values at a time).  Is there a similar statement in VB.NET?  Currently I have code like:

IF MyField <> "Male" AND MyField <> "Female" AND MyField <> "Both"
...
END

Thank you for any ideas!

Ben

Reply
Steve L. Taylor
Steve L. Taylor
StrataFrame Developer (102 reputation)
Group: StrataFrame Developers
Posts: 40, Visits: 91
Ben another version:


''' <summary>
''' Accepts an expression and a list of values.
''' <example>
''' Inlist("FULL", "FULL", "ACCD", "CIT", "PARK", "FI") ' Returns true
''' InList(456, 23, 456, 44, 357) ' Returns true
''' </example>
''' </summary>
''' <param name="Expression"></param>
''' <param name="Items"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function InList(ByVal Expression As Object, ByVal ParamArray Items() As Object) As Boolean
     Return Array.IndexOf(Items, Expression) > -1
End Function

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search