473,382 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

If (textbox.name == null) ? Howto

I am writing some code, and I wanna "ask" if an object name is not null (aka, the object exist) then do some work, else, do other work...

Of course, by doing "If (textbox.name == null)" I get the error NullReferenceException.

Example of what I want to do in a function that have a public textbox object:
private TextBox det;
public TextBox Det
{
get { return det; }
set { det = value; }
}


if (det.Name != "")
{
Funciones.Detalle(det, CodBrowse, this.Text);
}
May 10 '07 #1
5 3369
shweta123
692 Expert 512MB
Hi,

Please check with isDBNull instead of null.
e.g.

If IsDBNull(textbox.name) = True

end if
May 10 '07 #2
TRScheel
638 Expert 512MB
Hi,

Please check with isDBNull instead of null.
e.g.

If IsDBNull(textbox.name) = True

end if

Actually, I believe he's trying to see if the textbox exists... instead of

if (det.Name != null)

he should just do

if (det != null)
May 10 '07 #3
'This checks to see if there are spaces in a textbox(if textbox is empty).
'I'm not sure if the textbox field qualifies for null. I think we only use that in database fields(or instances).

Are you trying to see if the textbox is empty?

if textboxname.text = " " then

'code to do what you want or not want

end if
May 10 '07 #4
TRScheel
638 Expert 512MB
'This checks to see if there are spaces in a textbox(if textbox is empty).
'I'm not sure if the textbox field qualifies for null. I think we only use that in database fields(or instances).

Are you trying to see if the textbox is empty?

if textboxname.text = " " then

'code to do what you want or not want

end if
Use string.Empty instead of ""

If tomorrow they changed what an empty string was declared as, you would have to change all your code, but if you used string.Empty, it would be updated for you.
May 10 '07 #5
Try to use String.IsNullOrEmpty();

-Jati
May 11 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Andrzej | last post by:
Is it possible to call a function which name is given by a string? Let assume that I created a program which call some functions for example void f1(void), void f2(void), void f3(void). ...
4
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with...
14
by: Gidi | last post by:
Hi, For the last week, i'm looking for a way to make a TextBox always write in English (No matter what the OS default language is). i asked here few times but the answers i got didn't help me. i...
3
by: DotNetNewbie | last post by:
I am reading the book Teach Yourself Microsoft Visual Basic .Net 2003 in 21 Days. I am having trouble getting one of the exercises to work at the end of day 4. Exercises: 1. Create a new...
3
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. ...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
2
by: Benny | last post by:
Is there a way to trace exceptions and messages captured with the Enterprise Library to a custom destination like a text box or any other control? If not can anyone think of a way to "hack"...
1
by: colleen1980 | last post by:
Hi: Can any one please tell me that how to i pass the two textbox values in the new page. If i use the form action in the popup window page then the new page is open in the same popup window as i...
1
by: rakeshnair | last post by:
i wrote a code in jsp to create dynamic table..the problem is i need data base connection when cursor moves from one cell to other... eg...when i enter product id in the first cell, the product name...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.