I’m new to visual basic and have been using vb.net to create a console/text based game. I want to make my game a little bit more “smart”. The idea I’ve had to do this is to create an array of synonyms for yes and an array of synonyms for no, and similar arrays for over words. I intended on using a case statement with the array to decide weather the users input was a synonym for yes or for no. I have had no luck so far, and I was wondering if anybody here knew how it can be done or if I’m barking up the wrong tree. Maybe there is a different way for me to approach this?
My Select attempt:
Select Case userInput
Case yes(0) To yes(34)
Console.WriteLine("you said something like yes, you said {0}", userInput)
End Select
The start of my array: (there are 34 synonyms so far)
Dim yes(0 To 34) As String
yes(0) = "yes"
yes(1) = "ok"
yes(2) = "yep"
yes(3) = "yeah"
If anybody can help me it would be very much appreciated 🙂 Thank you very much!
You do not have to use a
Select Casefor this purpose. A simpleList(Of T).Containscan do the trick. Then you can go ahead to put it in a function so you can call it several times in your application.Sample Code: