jhylands

Yes no validation

Feb 2nd, 2012
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.88 KB | None | 0 0
  1. Private Function yesno() As Boolean
  2.         Console.WriteLine("y/n")
  3.         Select Case LCase(Console.ReadLine())
  4.             Case "y"
  5.                 yesno = True
  6.             Case "n"
  7.                 yesno = False
  8.             Case "yes"
  9.                 yesno = True
  10.             Case "no"
  11.                 yesno = False
  12.             Case "ok"
  13.                 yesno = True
  14.             Case "i would"
  15.                 yesno = True
  16.             Case "i would not"
  17.                 yesno = False
  18.             Case Else
  19.                 Console.WriteLine("I didn't understand your reply!")
  20.                 Console.WriteLine("Please answer with 'yes' for yes or anything else for no!")
  21.                 If Console.ReadLine() = "yes" Then
  22.                     yesno = True
  23.                 Else
  24.                     yesno = False
  25.                 End If
  26.         End Select
  27.     End Function
Advertisement
Add Comment
Please, Sign In to add comment