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

try catch question

I know this will sound like a really stupid question, but here goes.
I am in the middle of debugging someone else's code and am getting
more confused by the second. Does the try catch require an "end
Try"? There are try's and catches everywhere, but no end trys.

If when you get finished having a good laugh and feel up to posting a
reply, I would be most grateful for any advice.

Oh and if anyone knows of a quick way to check that braces match up -
I think the squiggly braces aren't always paired as they should be.

Thanks,
Dawn

Apr 26 '07 #1
12 1165
In VB, the complete construction is

Try
<protected statements>
Catch (optional exception variable as exception type)
<error handler>
Finally
<cleanup statements that will always run>
End Try.

C# uses

try {
<protected statements>
}catch (optional exception variable as exception type) {
<error handler>
}finally {
<cleanup statements that will always run>
}

Mike.

"dawn13" <da**********@wrightind.comwrote in message
news:11*********************@r3g2000prh.googlegrou ps.com...
>I know this will sound like a really stupid question, but here goes.
I am in the middle of debugging someone else's code and am getting
more confused by the second. Does the try catch require an "end
Try"? There are try's and catches everywhere, but no end trys.

If when you get finished having a good laugh and feel up to posting a
reply, I would be most grateful for any advice.

Oh and if anyone knows of a quick way to check that braces match up -
I think the squiggly braces aren't always paired as they should be.

Thanks,
Dawn

Apr 26 '07 #2
I know this will sound like a really stupid question, but here goes. I
am in the middle of debugging someone else's code and am getting more
confused by the second. Does the try catch require an "end Try"?
There are try's and catches everywhere, but no end trys.

If when you get finished having a good laugh and feel up to posting a
reply, I would be most grateful for any advice.

Oh and if anyone knows of a quick way to check that braces match up -
I think the squiggly braces aren't always paired as they should be.
Hey Dawn I think you're reading c# code not vb.net

So your code might look like

-------------------------------------------------------------
try
{
// try something
}
catch exception ex
{
// do some catch stuff
}
-------------------------------------------------------------

However the nature of c# allows for the braces to be placed on other lines
thus...
-------------------------------------------------------------
try {
// try something
}
catch exception ex {
// do some catch stuff
}
-------------------------------------------------------------

Note that the opening braces are not parrallel with the closing ones.

In this case (c#), the end brace '}' is equivilent to 'End Try'

I hope this helps

--
Rory
Apr 26 '07 #3
On Apr 26, 2:23 pm, Rory Becker <RoryBec...@newsgroup.nospamwrote:
I know this will sound like a really stupid question, but here goes. I
am in the middle of debugging someone else's code and am getting more
confused by the second. Does the try catch require an "end Try"?
There are try's and catches everywhere, but no end trys.
If when you get finished having a good laugh and feel up to posting a
reply, I would be most grateful for any advice.
Oh and if anyone knows of a quick way to check that braces match up -
I think the squiggly braces aren't always paired as they should be.

Hey Dawn I think you're reading c# code not vb.net

So your code might look like

-------------------------------------------------------------
try
{
// try something}

catch exception ex
{
// do some catch stuff}

-------------------------------------------------------------

However the nature of c# allows for the braces to be placed on other lines
thus...
-------------------------------------------------------------
try {
// try something}

catch exception ex {
// do some catch stuff}

-------------------------------------------------------------

Note that the opening braces are not parrallel with the closing ones.

In this case (c#), the end brace '}' is equivilent to 'End Try'

I hope this helps

--
Rory
All things are possible, and I am fairly new to .NET, however all of
the files in the project are named with VB conventions. All my forms
are something.vb, and I thought that indicated a VB.NET program.
Doesn't C# use a different naming convention; I thought .cs, but has
been awhile since I played around with.

Is it possible to use C# conventions in a vb.net program? Wouldn't it
cause a problem?

If I am understanding the answers posted here, VB does require a End
Try, but C# does not. That was my understanding as well. OK. So how
do I know for sure whether I am indeed working in VB or C#?

Thanks for the help,
Dawn

Apr 26 '07 #4
All things are possible, and I am fairly new to .NET, however all of
the files in the project are named with VB conventions. All my forms
are something.vb, and I thought that indicated a VB.NET program.
Doesn't C# use a different naming convention; I thought .cs, but has
been awhile since I played around with.

Is it possible to use C# conventions in a vb.net program? Wouldn't it
cause a problem?

If I am understanding the answers posted here, VB does require a End
Try, but C# does not. That was my understanding as well. OK. So how
do I know for sure whether I am indeed working in VB or C#?
The best way is to paste us some code and we'll have a look for you

The example try catch would do.

--
Rory
Apr 26 '07 #5
Rory and dawn,

Most of us in the microsoft newsgroup use Microsoft (upper) mailconventions
instead of the Apple/Netscape this means that we don't have to read to
endless messages. We aint anymore in the time that a message was 2 lines so
you could easily concat below that. Will you please do that to?

Thanks in advance,

Cor

"Rory Becker" <Ro********@newsgroup.nospamschreef in bericht
news:b0*************************@msnews.microsoft. com...
>All things are possible, and I am fairly new to .NET, however all of
the files in the project are named with VB conventions. All my forms
are something.vb, and I thought that indicated a VB.NET program.
Doesn't C# use a different naming convention; I thought .cs, but has
been awhile since I played around with.

Is it possible to use C# conventions in a vb.net program? Wouldn't it
cause a problem?

If I am understanding the answers posted here, VB does require a End
Try, but C# does not. That was my understanding as well. OK. So how
do I know for sure whether I am indeed working in VB or C#?

The best way is to paste us some code and we'll have a look for you

The example try catch would do.

--
Rory


Apr 27 '07 #6

Thats funny Cor. Whenever I post using this convention in other groups, I
have to put my flame retardant suit on!
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ez**************@TK2MSFTNGP04.phx.gbl...
Rory and dawn,

Most of us in the microsoft newsgroup use Microsoft (upper)
mailconventions instead of the Apple/Netscape this means that we don't
have to read to endless messages. We aint anymore in the time that a
message was 2 lines so you could easily concat below that. Will you please
do that to?

Thanks in advance,

Cor

"Rory Becker" <Ro********@newsgroup.nospamschreef in bericht
news:b0*************************@msnews.microsoft. com...
>>All things are possible, and I am fairly new to .NET, however all of
the files in the project are named with VB conventions. All my forms
are something.vb, and I thought that indicated a VB.NET program.
Doesn't C# use a different naming convention; I thought .cs, but has
been awhile since I played around with.

Is it possible to use C# conventions in a vb.net program? Wouldn't it
cause a problem?

If I am understanding the answers posted here, VB does require a End
Try, but C# does not. That was my understanding as well. OK. So how
do I know for sure whether I am indeed working in VB or C#?

The best way is to paste us some code and we'll have a look for you

The example try catch would do.

--
Rory



Apr 27 '07 #7
cj
Robin,

I too get flamed bad when I post at the top in many groups. One group,
and I don't remember which, someone told me if I didn't have the
courtesy to post at the bottom that I couldn't post there. When I told
them my feelings they went on to point out web etiquette articles and
tried to tell me posting at the bottom was the correct way. But I
believe like Cor, that top is best and most forums I see post at top
so.... Anyway because of my experiences I don't say anything when I see
someone here posting at the bottom.

Glad to see your actually a top poster at heart. :)
Robin Tucker wrote:
Thats funny Cor. Whenever I post using this convention in other groups, I
have to put my flame retardant suit on!
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:ez**************@TK2MSFTNGP04.phx.gbl...
>Rory and dawn,

Most of us in the microsoft newsgroup use Microsoft (upper)
mailconventions instead of the Apple/Netscape this means that we don't
have to read to endless messages. We aint anymore in the time that a
message was 2 lines so you could easily concat below that. Will you please
do that to?

Thanks in advance,

Cor

"Rory Becker" <Ro********@newsgroup.nospamschreef in bericht
news:b0*************************@msnews.microsoft .com...
>>>All things are possible, and I am fairly new to .NET, however all of
the files in the project are named with VB conventions. All my forms
are something.vb, and I thought that indicated a VB.NET program.
Doesn't C# use a different naming convention; I thought .cs, but has
been awhile since I played around with.

Is it possible to use C# conventions in a vb.net program? Wouldn't it
cause a problem?

If I am understanding the answers posted here, VB does require a End
Try, but C# does not. That was my understanding as well. OK. So how
do I know for sure whether I am indeed working in VB or C#?

The best way is to paste us some code and we'll have a look for you

The example try catch would do.

--
Rory


Apr 27 '07 #8
Cor Ligthert [MVP] wrote:
Rory and dawn,

Most of us in the microsoft newsgroup use Microsoft (upper) mailconventions
instead of the Apple/Netscape this means that we don't have to read to
endless messages. We aint anymore in the time that a message was 2 lines so
you could easily concat below that. Will you please do that to?

Thanks in advance,

Cor
Why are you top posting a thread that is not using top posting?

I don't care much if a thread uses top posting or bottom posting, as
long as the people in the thread can stick to the same style. It's when
someone is so rigit that he absolutely have to use his favorite style
regardless of what everybody else in the thread is using, that it gets
irritating.

--
Göran Andersson
_____
http://www.guffa.com
Apr 27 '07 #9
Goran,

As I wrote, I had not any problem with it when messages were 10 lines. I am
not starting writing this in this newsgroup, somebody else attended me at
the fact that with messages from 500 lines it is no fun anymore everytime to
have to scroll to the bottom.

I know from myself that I stop earlier to answer the bottom posters than the
topposters after a while.
However feel free to do it as you want.

Cor

"Göran Andersson" <gu***@guffa.comschreef in bericht
news:ug**************@TK2MSFTNGP05.phx.gbl...
Cor Ligthert [MVP] wrote:
>Rory and dawn,

Most of us in the microsoft newsgroup use Microsoft (upper)
mailconventions instead of the Apple/Netscape this means that we don't
have to read to endless messages. We aint anymore in the time that a
message was 2 lines so you could easily concat below that. Will you
please do that to?

Thanks in advance,

Cor

Why are you top posting a thread that is not using top posting?

I don't care much if a thread uses top posting or bottom posting, as long
as the people in the thread can stick to the same style. It's when someone
is so rigit that he absolutely have to use his favorite style regardless
of what everybody else in the thread is using, that it gets irritating.

--
Göran Andersson
_____
http://www.guffa.com

Apr 28 '07 #10
Cor Ligthert [MVP] wrote:
Goran,

As I wrote, I had not any problem with it when messages were 10 lines. I am
not starting writing this in this newsgroup, somebody else attended me at
the fact that with messages from 500 lines it is no fun anymore everytime to
have to scroll to the bottom.
The solution to that is to quote properly. The problem is not that the
reply is at the bottom of the message, it's that the message is too
long. The logical solution would be to fix the problem, not to
circumvent the problem by introducing another one.
I know from myself that I stop earlier to answer the bottom posters than the
topposters after a while.
And is the reason really that they are posting at the bottom, or that
they are quoting to much of the previous conversation? I think that you
are focusing on the wrong issue.
However feel free to do it as you want.

Cor

"Göran Andersson" <gu***@guffa.comschreef in bericht
news:ug**************@TK2MSFTNGP05.phx.gbl...
>Cor Ligthert [MVP] wrote:
>>Rory and dawn,

Most of us in the microsoft newsgroup use Microsoft (upper)
mailconventions instead of the Apple/Netscape this means that we don't
have to read to endless messages. We aint anymore in the time that a
message was 2 lines so you could easily concat below that. Will you
please do that to?

Thanks in advance,

Cor
Why are you top posting a thread that is not using top posting?

I don't care much if a thread uses top posting or bottom posting, as long
as the people in the thread can stick to the same style. It's when someone
is so rigit that he absolutely have to use his favorite style regardless
of what everybody else in the thread is using, that it gets irritating.

--
Göran Andersson
_____
http://www.guffa.com


--
Göran Andersson
_____
http://www.guffa.com
Apr 28 '07 #11
On Apr 27, 7:17 am, cj <c...@nospam.nospamwrote:
Robin,

I too get flamed bad when I post at the top in many groups. One group,
and I don't remember which, someone told me if I didn't have the
courtesy to post at the bottom that I couldn't post there. When I told
them my feelings they went on to point out web etiquette articles and
tried to tell me posting at the bottom was the correct way. But I
believe like Cor, that top is best and most forums I see post at top
so.... Anyway because of my experiences I don't say anything when I see
someone here posting at the bottom.

Glad to see your actually a top poster at heart. :)

Robin Tucker wrote:
Thats funny Cor. Whenever I post using this convention in other groups, I
have to put my flame retardant suit on!
"Cor Ligthert [MVP]" <notmyfirstn...@planet.nlwrote in message
news:ez**************@TK2MSFTNGP04.phx.gbl...
Rory and dawn,
Most of us in the microsoft newsgroup use Microsoft (upper)
mailconventions instead of the Apple/Netscape this means that we don't
have to read to endless messages. We aint anymore in the time that a
message was 2 lines so you could easily concat below that. Will you please
do that to?
Thanks in advance,
Cor
"Rory Becker" <RoryBec...@newsgroup.nospamschreef in bericht
news:b0*************************@msnews.microsoft .com...
All things are possible, and I am fairly new to .NET, however all of
the files in the project are named with VB conventions. All my forms
are something.vb, and I thought that indicated a VB.NET program.
Doesn't C# use a different naming convention; I thought .cs, but has
been awhile since I played around with.
>>Is it possible to use C# conventions in a vb.net program? Wouldn't it
cause a problem?
>>If I am understanding the answers posted here, VB does require a End
Try, but C# does not. That was my understanding as well. OK. So how
do I know for sure whether I am indeed working in VB or C#?
>The best way is to paste us some code and we'll have a look for you
>The example try catch would do.
>--
Rory- Hide quoted text -

- Show quoted text -
Common Usenet etiquet is to post at the bottom - except for inline
replies. This allows the flow of the conversation to be followed,
even if you only get a partial message. It helps keep context.

Yes, you will see a lot of top posting on microsoft forums, but many
people are posting here using outlook express or a web interface.
outlook express encourages top posting by automatically putting the
cursor on top - most other readers start you at the bottom.

I guarentee you that if you go to most non-microsoft forums, you will
find that top posting is not appriciated.

--
Tom Shelton

Apr 28 '07 #12
Yes, you will see a lot of top posting on microsoft forums, but many
people are posting here using outlook express or a web interface.
outlook express encourages top posting by automatically putting the
cursor on top - most other readers start you at the bottom.
Actually that is the main point - its just easier to start typing where-ever
the cursor is placed - and yes I used outlook. I didn't try with other
newsreaders but its all perfectly understandable I suppose. Of course when
quoting as above, its better to post underneath ;).

Robin
Apr 30 '07 #13

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

Similar topics

5
by: Jacek Dziedzic | last post by:
Hi! In my main() function I have a last-resort exception construct that looks like this: int main() { try { // ... program code }
13
by: Woody Splawn | last post by:
I have a try catch statement in a fucntion that is supposed to return a true or a false My code looks like this: Try mySqlConnection.Open() Dim Da1 As New SqlDataAdapter("Select JnlType,...
7
by: Tiraman | last post by:
Hi , I am using allot the try catch in my code and the question is if it is good ? it will decrease my performance ? one more question
9
by: Michael MacDonald | last post by:
Does someone have a good site I can visit or explain the use of Try" and Catch foe exception/error handling. What is the logic behind this command and maybe an example would be great!!!! Mike_Mac...
2
by: Keith Kowalski | last post by:
I anm opening up a text file reading the lines of the file that refer to a tif image in that file, If the tif image does not exist I need it to send an email stating that the file doesn't exist...
5
by: Patrick Dickey | last post by:
Hello, All! I'm modifying some source code that I downloaded from Planet-source-code a while back, and have a question about Try Catch statements. Basically, I'm wondering if I can do a Try with...
32
by: cj | last post by:
Another wish of mine. I wish there was a way in the Try Catch structure to say if there wasn't an error to do something. Like an else statement. Try Catch Else Finally. Also because I...
23
by: pigeonrandle | last post by:
Hi, Does this bit of code represent complete overkill?! try { //create a treenode TreeNode tn = new TreeNode(); //add it to a treeview tv.Nodes.Add(tn);
6
by: rhaazy | last post by:
I am looking for some feedback on using try catch statements. Usually when I start a project I use them for everything, but stop using them as often after the "meat n' potatos" of the project is...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.