try catch question

D

dawn13

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
 
M

Michael D. Ober

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.
 
R

Rory Becker

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
 
D

dawn13

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

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
 
R

Rory Becker

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.
 
C

Cor Ligthert [MVP]

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
 
R

Robin Tucker

Thats funny Cor. Whenever I post using this convention in other groups, I
have to put my flame retardant suit on!


Cor Ligthert said:
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
 
C

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 said:
Thats funny Cor. Whenever I post using this convention in other groups, I
have to put my flame retardant suit on!
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Cor said:
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.
 
C

Cor Ligthert [MVP]

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
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Cor said:
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
 
T

Tom Shelton

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. :)






- 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.
 
R

Robin Tucker

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top