2 Replies - 723 Views - Last Post: 26 March 2008 - 03:27 PM Rate Topic: -----

#1 andrew2008  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-March 08

how to check text

Posted 26 March 2008 - 02:37 PM

hey i'm trying to create a program and want it to check if the text in a text box is = to either "y" or "n"

   If TextBox5.Text <> "y" Or TextBox2.Text <> "n" Then
			MessageBox.Show("please input Y or N", "id10t error", MessageBoxButtons.OK, MessageBoxIcon.Error)
			TextBox5.Select()
		End If


thats what i'd figured out so far but of course it wont work because if it IS y then its not n so it will still display the error can someone please help me out with the right code?

Is This A Good Question/Topic? 0
  • +

Replies To: how to check text

#2 gymratz  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 129
  • Joined: 18-October 07

Re: how to check text

Posted 26 March 2008 - 03:00 PM

View Postandrew2008, on 26 Mar, 2008 - 02:37 PM, said:

hey i'm trying to create a program and want it to check if the text in a text box is = to either "y" or "n"

   If TextBox5.Text <> "y" Or TextBox2.Text <> "n" Then
			MessageBox.Show("please input Y or N", "id10t error", MessageBoxButtons.OK, MessageBoxIcon.Error)
			TextBox5.Select()
		End If


thats what i'd figured out so far but of course it wont work because if it IS y then its not n so it will still display the error can someone please help me out with the right code?



My first guess would be:
If TextBox5.Text <> "y" AND TextBox2.Text <> "n" Then

That way if it is Y or N, it will not pass (because only one would be true). If it is anything else then it will pass this statement and you can proceed with calling them an idiot.
Was This Post Helpful? 0
  • +
  • -

#3 andrew2008  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-March 08

Re: how to check text

Posted 26 March 2008 - 03:27 PM

wont that check if the textbox is y ( asssuming it is , get a yes value) and then check if its n ( and get a no value) so will still display the error message even though it is y?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1