L
L
libera2016-03-23 14:28:08
C++ / C#
libera, 2016-03-23 14:28:08

Checking conditions on letters?

string bukv = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            if (textBox.Text != bukv)
            {
            }
            else
            {
                MessageBox.Show("Ошибка: Регистр букв должен быть большим и на Английском языке.");
            }

There is such a code. But it is not working, I need to do it, so that there would be a spell check, if such a letter does not occur, then an error.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
amf1k, 2016-03-23
@libera

Read about regular expressions

D
Dmitry Kovalsky, 2016-03-23
@dmitryKovalskiy

Well, you can raise the register yourself - you won’t break and you probably shouldn’t throw an error about it. And the letters themselves are checked by regular expressions - and quite simple ones. If you are really bad with them - https://regex101.com you can practice here.

T
Tsiren Naimanov, 2016-03-23
@ImmortalCAT

bool state = false;
foreach(ch in textBox.Text)
{
      if(!char.IsUpper(ch))
      state = true;
}
if(state)
   MessageBox.Show("Ошибка: Регистр букв должен быть большим и на Английском языке.");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question