Chris
"Yuelin" <liang@lineone. net> wrote in message
news:#OCYJxPXDH A.608@TK2MSFTNG P12.phx.gbl...[color=blue]
> Hi there
>
> What's the best way of checking whether a textbox is empty? Thanks.
>
> Yuelin
>
>[/color]
In article <#OCYJxPXDHA.60 8@TK2MSFTNGP12. phx.gbl>, liang@lineone.n et says...[color=blue]
> Hi there
>
> What's the best way of checking whether a textbox is empty? Thanks.
>
> Yuelin
>
>
>[/color]
Subclass TextBox and add a IsEmpty Method
class MyTextBox : TextBox
{
public bool IsEmpty()
{
return (TextBox.Text == "")
}
"Mark Marsella" <news@tersus-solutions.com> wrote in message
news:MPG.199c92 9ebd38c93798968 a@news.cis.dfn. de...[color=blue]
> Subclass TextBox and add a IsEmpty Method[/color]
It doesn't really matter but it goes back to that magic number thing.
There should never be an instance theoretically that you should ever
have to put a string or number in your program.
Nick
Mark Marsella wrote:
[color=blue]
> In article <#OCYJxPXDHA.60 8@TK2MSFTNGP12. phx.gbl>, liang@lineone.n et says...
>[color=green]
>>Hi there
>>
>>What's the best way of checking whether a textbox is empty? Thanks.
>>
>>Yuelin
>>
>>
>>[/color]
>
>
> Subclass TextBox and add a IsEmpty Method
>
> class MyTextBox : TextBox
> {
>
> public bool IsEmpty()
> {
> return (TextBox.Text == "")
> }
>
> }[/color]
I read somewhere that checking the string's length is a faster operation.
Although the performance gain would probably only be useful in a loop, and
there's little chance you're doing this in a loop...
~Greg
"Chris Capel" <chris@nowhere. com> wrote in message
news:#cdAa1PXDH A.1384@TK2MSFTN GP10.phx.gbl...[color=blue]
> If you want to ignore spaces, then
>
> textBox1.Text.T rim() == ""
>
> otherwise use
>
> textBox1.Text == ""
>
> Chris
> "Yuelin" <liang@lineone. net> wrote in message
> news:#OCYJxPXDH A.608@TK2MSFTNG P12.phx.gbl...[color=green]
> > Hi there
> >
> > What's the best way of checking whether a textbox is empty? Thanks.
> >
> > Yuelin
> >
> >[/color]
>
>[/color]
Comment