Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

Searching for multiple possible values in a text box

$
0
0

Hello. I have made an Enum  in visual basic to hold different objects. As an example I will say it was Fruit.

Public Enum Fruit
Banana
Apple
Orange
Watermelon
End Enum

Then I have a text box. In this text box the user could type a fruit. What I want to do is have code that will be able to recognize if this text contains a possible value of the Enum Fruit, then subsequently find which value it is.

What I have now is this:

Private Sub txtTextEntry_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtTextEntry.KeyDown
        If e.KeyCode = Keys.Enter Then
            Dim Search As Fruit
            Search = Fruit.All

        End If

End Sub

I realize that Fruit.All does not actually do anything, but that is the kind of effect I wish to have. Any suggestions?




Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>