473,387 Members | 1,650 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,387 software developers and data experts.

Putting 2 checks on the same line when Object might be Nothing

Hi all

At the moment I am using the following code to check to see if the
oTempDataSet is not nothing and that it has tables in it:

If Not oTempDataSet Is Nothing Then
If oTempDataSet.Tables.Count > 0 Then
End If
End If

Is it possible using new language features in .NET to put both the checks on
the same line? In older versions of VB it would not be possible because if
oTempDataSet is Nothing then checking the Tables.Count property would result
in an error. I'm not sure, but I think I read something a while ago on
short-circuiting in C++ where if the first condition was false then the
second condition was not checked, even though the code is on the same line.

Thanks for any help.

Kind Regards,
Steve.
Nov 21 '05 #1
2 1091
Take a look at the AndAlso operator.

Robby

"Steve Amey" <stevea@centurion-ms_RemoveThis_.co.uk> wrote in message
news:OE**************@TK2MSFTNGP15.phx.gbl...
Hi all

At the moment I am using the following code to check to see if the
oTempDataSet is not nothing and that it has tables in it:

If Not oTempDataSet Is Nothing Then
If oTempDataSet.Tables.Count > 0 Then
End If
End If

Is it possible using new language features in .NET to put both the checks
on
the same line? In older versions of VB it would not be possible because if
oTempDataSet is Nothing then checking the Tables.Count property would
result
in an error. I'm not sure, but I think I read something a while ago on
short-circuiting in C++ where if the first condition was false then the
second condition was not checked, even though the code is on the same
line.

Thanks for any help.

Kind Regards,
Steve.

Nov 21 '05 #2
Hi Robby

Lovely stuff.

Just did a quick search on Short-Circuiting and guess what came up....! I
really need to put more faith in my memory, or at least do a scan of the
help files first. Thanks for your response.

Steve.

"Robby" <ed****@not.my.email.com> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
Take a look at the AndAlso operator.

Robby

"Steve Amey" <stevea@centurion-ms_RemoveThis_.co.uk> wrote in message
news:OE**************@TK2MSFTNGP15.phx.gbl...
Hi all

At the moment I am using the following code to check to see if the
oTempDataSet is not nothing and that it has tables in it:

If Not oTempDataSet Is Nothing Then
If oTempDataSet.Tables.Count > 0 Then
End If
End If

Is it possible using new language features in .NET to put both the checks on
the same line? In older versions of VB it would not be possible because if oTempDataSet is Nothing then checking the Tables.Count property would
result
in an error. I'm not sure, but I think I read something a while ago on
short-circuiting in C++ where if the first condition was false then the
second condition was not checked, even though the code is on the same
line.

Thanks for any help.

Kind Regards,
Steve.


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Cristian Gutierrez | last post by:
Hello all, Is there any way to trigger "undefined variable/constant" error notices when running `php -l' over a source file? Or even better, when using php_check_syntax() over the file? So...
6
by: DLP22192 | last post by:
I have the following single-line if statement that is evaluating true even though it shouldn't. I have never seen this before and I am concerned that this can happen in other areas of my code. ...
0
by: Erwin | last post by:
I'm working on a report. Within this report a chart (line chart) is build which shows how many suggestions have been made per servicegroupe. Now I have put such a chart into the report, but the...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
12
by: James Norton-Jones | last post by:
Hi, Am I trying to hold the data of a DataGrid in a label so that when the form is reposted the DataGrid can be repopulated. The problem I am having is that I don't understand how to get the...
6
by: Beren | last post by:
Hey, I've got some code in my Session_End which cleans up all Session related items from the Cache object. I needed to store some related sessiondata in there to be able to address it in the...
6
by: Nicola Mezzetti | last post by:
Greetings, I write to ask information about how to disable the preprocessor checks on macros when compiling with command line Borland C++ compiler. Waiting for a reply, i thank you all for the...
17
by: Plissken.s | last post by:
Hi, Can you please tell me what is the guideline in Putting implmentation in .h files? I see examples where they put the implementation of getter/setting in the .h files where funcitons is > 10...
5
by: GG | last post by:
Any thoughts on designing classes wheather to throw the exception and the consumer has to capture it on try catch or wrap all the methods in a main method This is the wrap logic MainMethod{ bool...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.