Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / April 2007

Tip: Looking for answers? Try searching our database.

try catch question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dawn13 - 26 Apr 2007 20:07 GMT
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
Michael D. Ober - 26 Apr 2007 20:20 GMT
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.

>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
[quoted text clipped - 9 lines]
> Thanks,
> Dawn
Rory Becker - 26 Apr 2007 20:23 GMT
> 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
[quoted text clipped - 6 lines]
> 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
dawn13 - 26 Apr 2007 22:58 GMT
> > 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
[quoted text clipped - 41 lines]
> --
> 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
Rory Becker - 26 Apr 2007 23:42 GMT
> 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
[quoted text clipped - 8 lines]
> 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
Cor Ligthert [MVP] - 27 Apr 2007 01:51 GMT
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

>> 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
[quoted text clipped - 15 lines]
> --
> Rory
Robin Tucker - 27 Apr 2007 12:28 GMT
Thats funny Cor.  Whenever I post using this convention in other groups, I
have to put my flame retardant suit on!

> Rory and dawn,
>
[quoted text clipped - 27 lines]
>> --
>> Rory
cj - 27 Apr 2007 14:17 GMT
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. :)

> Thats funny Cor.  Whenever I post using this convention in other groups, I
> have to put my flame retardant suit on!
[quoted text clipped - 30 lines]
>>> --
>>> Rory
Tom Shelton - 28 Apr 2007 17:15 GMT
> Robin,
>
[quoted text clipped - 45 lines]
>
> - 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
Robin Tucker - 30 Apr 2007 10:20 GMT
> 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
Göran Andersson - 27 Apr 2007 20:00 GMT
> Rory and dawn,
>
[quoted text clipped - 6 lines]
>
> 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.

Signature

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

Cor Ligthert [MVP] - 28 Apr 2007 06:04 GMT
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

>> Rory and dawn,
>>
[quoted text clipped - 14 lines]
> 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 - 28 Apr 2007 12:06 GMT
> 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.
>
[quoted text clipped - 18 lines]
>> 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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.