473,666 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ta bles.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 1104
Take a look at the AndAlso operator.

Robby

"Steve Amey" <stevea@centuri on-ms_RemoveThis_. co.uk> wrote in message
news:OE******** ******@TK2MSFTN GP15.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.Ta bles.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******** ******@TK2MSFTN GP11.phx.gbl...
Take a look at the AndAlso operator.

Robby

"Steve Amey" <stevea@centuri on-ms_RemoveThis_. co.uk> wrote in message
news:OE******** ******@TK2MSFTN GP15.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.Ta bles.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
1616
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 far I've noticed that I only get those errors when actually *running* the script, and I'm beggining to suspect there's little more (if at all) to do without getting dirty with a PHP language parser. For example, when I run the following script:
6
8171
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. If String1.Length > 0 Then String2 = String1 where String1 = "" This statement also evaluates as true when String1 = "":
0
1449
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 layout just isn't what I want it to be. In the X and Y axes you can see some numbers 1 to 10. That isn't what I've been looking for. I'm looking for an X axe which shows the month which I would like to view. The Y axe must show the percentage of the...
6
3313
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 parameter query which is the recordsource for the report. The parameter is <=. The query returns the correct amounts upto the date entered (no need for "between" dates here). There are 8 textboxes with dcounts; 2 other boxes Sum some of these
12
2868
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 text into a stream in order to be able to use DataSetOutcomes1.ReadXML(MyStream). Thanks in advance, James
6
1441
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 AuthenticateRequest event. Now when I breakpoint the first line to test the Session_End code, it only breaks on the first line. A press on F11 through will just jump me out and resumes the program,
6
2144
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 kindness and availability. Best regards, nicola --
17
1797
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 lines of code are put in .cpp file. Is that the guideline?
5
1454
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 mainRun = false; try { methods... mainRun = true;
0
8438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1761
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.