ICeMaN_179 Posted January 7, 2003 Posted January 7, 2003 i am using is null in my code and i get a compile error and the debugger says that NULL needs to be declared, what does this need to be declared as ? dim NULL as ??? Quote
*Experts* Bucky Posted January 7, 2003 *Experts* Posted January 7, 2003 In VB.NET, to check if a class is not inialized, use Is Nothing: If myObj Is Nothing Then ' Moo End If Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
ICeMaN_179 Posted January 7, 2003 Author Posted January 7, 2003 would it be: (this didn't work for me) if TXTInput is nothing then msgbox "Please enter text !!", msgstyle.question, "Error" else exit sub end if Quote
Leaders John Posted January 7, 2003 Leaders Posted January 7, 2003 Try this:If TXTInput.Text = "" Then msgbox "Please enter text !!", msgboxstyle.question, "Error" End IfOrbity Quote "These Patriot playoff wins are like Ray Charles songs, Nantucket sunsets, and hot fudge sundaes. Each one is better than the last." - Dan Shaughnessy
ICeMaN_179 Posted January 7, 2003 Author Posted January 7, 2003 yeh i know that but i would prefer to use something like, Is Nothing ' or Is Null Quote
*Experts* Volte Posted January 8, 2003 *Experts* Posted January 8, 2003 Why? Null, Nothing and "" are all different things, and so can't be interchanged. "" is a string, while Nothing is.... nothing. It's the lack of anything in the Text object. Stick with "". If you want to do it a different way, you could use If txtInput.Text.Length = 0 Then. :-\ Quote
*Experts* Nerseus Posted January 8, 2003 *Experts* Posted January 8, 2003 I know in C# you can use string.Empty (or String.Empty). The fastest method will always be to check the length, VolteFace's last comment. If txtInput.Text.Length = 0 Then Strings are objects in .NET and contain a header which contains, among other things, the length. It's faster to compare that a known number than to check for "" (or even string.Empty). -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
*Gurus* divil Posted January 8, 2003 *Gurus* Posted January 8, 2003 Nerseus is correct, never compare a string to "", always check the length. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.