C# winforms textbox

Posts 1–7 of 7 · Page 1 of 1
C# winforms textbox
How can i make my app check if theres text in textbox...for example....
Code:
  if (textBox1.Text == "if it has text" )
                Process.Start(textBox1.Text + ".exe");
            else
                MessageBox.Show("You must type something...");
I know that wont work but i can't figure out how to make it check for text.
Off the top of my head the C solution is simple.
[php]
#include ctype.h
if(isspace(text.Box1.Text))
MessageBox.Show("you must type something");

else
Process.Start(textBox1.Text + ".exe");
[/php]
~
But C# is something much different from C/C++
Quote Originally Posted by Arhk View Post
Off the top of my head the C solution is simple.
[php]
#include ctype.h
if(isspace(text.Box1.Text))
MessageBox.Show("you must type something");

else
Process.Start(textBox1.Text + ".exe");
[/php]
~
But C# is something much different from C/C++
i know but no where else to put c# stuff =/
I was thinking VB should be turned into VB/C# since, besides basic syntax C/C++ shares nothing in common with C# for us to be giving any kind of real indepth advice.
~
I think it's something like this:

[Code]

if(textBox1.Text==""){
MessageBox(NULL,"Type something","Warning",MB_OK);
}
else Process.Start(textBox1.Txt + ".exe");
That code only accounts for the space not things like carriage return backspace or even the EOL character that would be submitted if they were actually able to return nothing at all.
~
If C# has some sort of library function for this look it up at msdn. Otherwise you could create a function that test the beginning char value for an escape sequence (ASCII list).
But I'm sure C# does have a function for testing for escape sequences.
Common ways to check you have some text in a text box are:

if(textBox1.Text != "")
..

if(textBox1.Text != string.Empty)
..

or

if(textBox1.Text.Length != 0)
...

or
if(!string.IsNullOrEmpty(textBox1.Text))
...

Take your pick
Posts 1–7 of 7 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us