Solved

Correct Code Execution Path

Posted on 2011-09-27
1
191 Views
Last Modified: 2012-05-12
I am curious that if you have a function that uses a using keyword, should the return element come the end using or does it not matter

ie this is what I have

    Using log As New EventLog(EVENTLOGNAME)

                Dim errors(log.Entries.Count - 1) As structLoggedError

                For Each entry In log.Entries
                    Using reader As New StringReader(entry.Message)
                        errors(i) = CType(serializer.Deserialize(reader), structLoggedError)
                        i += 1
                    End Using
                Next

                Return errors <<<<<<<<<<<

            End Using
0
Comment
Question by:rocky050371
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
eguilherme earned 500 total points
ID: 36709100
it doesnt matter, you can place the return statement inside the using clause, it will dispose the used object as it should

http://msdn.microsoft.com/en-us/library/htd05whh.aspx
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question