Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2008, 07:25 AM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default empty string

Hi,

I'm new to programming with visual basic.
I used Access before.

In acces the code to test for empty or null string should be:

If me.txtName = "" or me.txtName is Null then

But this gives an error in VB Express 2008.
What is the code to use to be able to check this?

Thanks

 
Old October 26th, 2008, 11:32 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Null is Nothing in VB.NET:

If Me.txtName = "" or Me.txtName Is Nothing then

However, an easier and preferred method is IsNullOrEmpty on the string class:

If Not String.IsNullOrEmpty(txtName) Then

End If

If txtName is a control rather than a string, you need to use its Text property:

If Not String.IsNullOrEmpty(txtName.Text) Then

End If

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old October 29th, 2008, 03:24 PM
Friend of Wrox
 
Join Date: Apr 2006
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much.
This solved my problem :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
isNot nothing vs. string.empty julianfraser BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 June 8th, 2008 02:00 PM
Is String.Empty spinout ASP.NET 2.0 Basics 6 July 10th, 2007 05:55 AM
Difference between null and empty string shoakat Classic ASP Databases 4 September 10th, 2004 11:40 AM
Checking for empty string richw32001 General .NET 1 August 8th, 2004 01:37 PM
Convert empty string to double adriant42 Excel VBA 2 June 8th, 2004 04:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.