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

Replies
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ben,



Did you know there was a general .NET forum here? Click on the home link (under your name above the Add Post, Reply buttons) and down at the bottom you'll see a .NET forum. Its just for this sort of thing. The SF developers don't care much were you post it, as they get emails for new posts (based on what Ben Chase has said), but for us normal uses, it helps Hehe



I'm really curious to know if this can happen in VB.NET, BTW BigGrin
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
There is not an INLIST method in VB.NET.  Generally when I have a situation like this, I would not use a String field.  This would be a integer field then I would create an Enum for each of the values.  You can then do a bitwise test depending upon how you create the enum. 
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
Thanks Trent.  Unfortunately we have to support a legacy database that cannot be changed.

Ben

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
No fun.  You could easily create this type of functionality by creating a shared class and a collection.

Public Sub NotInheritable MyCommonTools
    Public Shared Function InList(ByVal TestValue as String, ParamArray TestItems() As String) As Boolean
       '-- Cycle through and test the values here and return out
    End Sub
End Sub

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