|
I still have no idea what sort of macro you're talking about, or how this relates to VB.NET programming.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I m sorry if my question was not relevent, In VS 2005, I have added my Block of code which will run as macro. The same is visible in the VS 2005 Macro-Explorer, But while running(Clicking on the Macro) only it has given the above mentioned Error.
Sabarinathan T, India.
The interests are to know something about everything and everything about something...
|
|
|
|
|
Hello every one
I am working on a VB 2005 application which was originally a VB6 application and is converted to VB 2005 Express.
I tried using Microsoft FxCop to check the application, I am having following issues
- I was naming my objects with "_" in vb6 and all the objects which were created in VB6 are not showing any issues but all the objects created in VB.net 2005 were showing Breaking errors with very high Certainty
- I changed the name of Objects created in VB.net as per the naming convention of .net. Still I am getting a error asking to start the object prefix (lbl/frm/cmb…) with Upper case letters which is again against the naming convention of vb.net
- It is also having issues with the spellings of the object. Will that actually affect
- What about all the objects created in VB6, am I also supposed to change the naming convention of them also?
Can any one plz help me with this..
Regards
Nishkarsh
|
|
|
|
|
FXCop doesn't tell you your code is broken, only that it doesn't follow a standard that FXCop enforces. Why do you need to pass it ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
how to call the data from other table? let say i want to generate a doc number that is in this format <yyyymmdd><custid><running no="">. i don't know how to call the value field run_no from table runNO. the doc no formula is
docNo = System.DateTime.Now.ToString("yyyyMMdd") + Kod.Text + "values from run_no (table runNO)"
rite now my docNo only have <20080216><brt50>... helppppppppp...
|
|
|
|
|
Perhaps if you could explain yourself a bit better ? Does table mean a SQL database ? You get data out of a table by querying it with SQL.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i'm doing a program using microsoft visual studio. each time i submit my data, it will generate a doc number that is in <yyyymmdd><custid><running number="">. My formula
docNo = System.DateTime.Now + kod + <running number="">. kod is the value from a text box. for running number, i have a function GetRunNo that will update a table in my sql database each time i submit a data. in the table there r 2 field that is run_no and date. Each time i click add button it will update the running number base on date, it will add the data in the database, and each data will have a doc number for our reference. how can i call the values in that table to put in the doc number?
|
|
|
|
|
I'm trying to add some generic analog and digital TV capabilities to a program, and I'm having some difficulties with DVB-T.
I'm using the MS Tuner Library, and the MS Video Control ActiveX, and am able to get correct image and audio for most cases... but I'm not able to find how to make an automatic scan function (already done this with the Analog TV but this one seems to be different), don't know how to get the provider and service name, and when I try to view one of the channels the msvidctl control doesn't show the image and crash, but the frequency, transport stream ID and service ID is correct.
Also, couldn't check how to select multiple languages so far (no programs with it right now), nor found anything regarding the Teletext display.
Any help?
|
|
|
|
|
I have a requirement to repeat a block of fields for each record in a dataset. This would be easlily done in VS 2005 ASP.Net with a DataGridView and a template column.
How is this done in Windows forms with VS 2005?? I had though that I could create a user control with the appropriate layout and add that to a list control of some sort...but there didn't seem to be any likely candidates.
Must one add the controls and do the data binding by hand?
Thanks for any help available.
|
|
|
|
|
Well I've discovered I still dont' know where to put a global try...catch block in vb.net. I figured it would go in the Mainform.mybaseload method but that doesn't seem to do it.
Thanks.
|
|
|
|
|
Hi again,
this is how it is done in C#:
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try {
Application.Run(new myMainForm());
} catch(Exception exc) {
log(exc.ToString());
}
}
}
The above code instantiates and executes the main form class.
For a regular Windows app, VB.NET seems not to rely on a Main() method, but directly
launches the startup object.
However I trust in a VB.NET module you could do exactly what the C# code does.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Can I disable my try..catch block handling while debugging? Thanks
|
|
|
|
|
Nope. It's part of your code. You'll have to comment it out before you start the debugger.
|
|
|
|
|
Too bad..that's why making too many of them makes it difficult to debug.
|
|
|
|
|
Not really. It's how you break down your problems and what you put in the Try/Catch block that really matters. (Hint, hint)
Also, it helps if you're not putting the bulk of your method code in the Try block. Keep the Try/Catch blocks small, encompasing only very small operations. Say you have a method that queries a database, then loops through the returned recordset and sends an email to every address it finds. There's a ton of places this can fall on its face. Do you put all of this in a single Try/Catch block?? Nope.
Really, this can be broken down into a bunch more methods, each handling very small parts of the process. Creating and returning a connection to the database is one, exectuing an arbitrary query is another, iterating over a dataset, pulling email addresses out, sending an email to an address, ... These are all seperate methods, each with it's own Try/Catch opportunities. The more atomic the operation of each method, the better.
Luc just nailed it in his post here[^].
modified on Friday, February 15, 2008 1:27 PM
|
|
|
|
|
In my experience, it is not the number of the try-catches that poses a problem;
a lot of people seem to stuff the catch blocks with MessageBox.Show which is a
terrible idea, since now you get tired of reading messages, one at a time, and having
to close them over and over again.
I prefer to provide a simple "log" method that takes a single string input, and
logs it somehow. I then implement the log based on Console.WriteLine, a file operation,
a listbox operation, or whatever suits my needs at the time. The advantages are:
- I don't have to interact with this logging
- I get it all sequentially (I tend to automatically add a timestamp too)
- I can save it, and compare different runs
I often temporarily add a ListBox to my main form, just for showing the logging.
MessageBox really is not my prefered debugging tool!
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
What I'm mostly having trouble with is determining where the error is, not the error handling itself. When my method is big, I can't tell where the error occurs within it, when it's running from the .exe on a different machine.
I don't seem to be getting any line numbers to help out. Perhaps I'm not in debug mode, although the .exe is written to the debug directory.
Thanks again.
|
|
|
|
|
strange, I just did a little VB app (VS2005 VB.NET Express) with a deliberate error,
and it exceptioned with the correct line number right away.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
cstrader232 wrote: not the error handling itself. When my method is big, I can't tell where the error occurs within it
This is a hint that your method is too big and needs to be broken down into smaller pieces. Also, it sounds like you're putting way too much inside the Try block. A Try block should encompass as few lines as possible that can fail. You don't wrap an entire method. You wrap small sections where each section has a specific task.
|
|
|
|
|
Hi Dave,
I beg to differ on this one, I would put as much code in a try block as logic dictates.
If my method needs 100 simple steps without any side-effects, and I don't care where
it fails, I'll put them all in a single try.
The net result would be either success, or failure in which case the details
of the failure are (should be) apparent from the exception, and probably the catch
block would contain code to throw an application-specific new exception (and store the
original as an inner exception).
If on the other hand, the steps have lots of side-effects (allocating resources,
opening files, etc) I would use more try/catch/finally blocks, even nested, to
handle this elegantly.
But I would avoid the fully sequential try one step, catch, try next step, ... approach
since then there could well be more error handling code than straight code, yielding lower
programmer efficiency, more code and more execution paths to test.
I do stress the use of line numbers while debugging though, a simple technique a lot
of people seem unfamiliar with (the fact that the Visual Editor by default does not
show them looks like a mistake to me).
Regards,
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: I beg to differ on this one, I would put as much code in a try block as logic dictates.
If my method needs 100 simple steps without any side-effects, and I don't care where
it fails, I'll put them all in a single try.
True. I guess I tailored my answer to his case. If he can't find where the offending code is, that's a sign he's got too much in the Try block.
I try to keepo me Try's as small as possible, but it, agreeably, depends on the situation.
Luc Pattyn wrote: But I would avoid the fully sequential try one step, catch, try next step, ... approach
since then there could well be more error handling code than straight code, yielding lower
programmer efficiency, more code and more execution paths to test.
I think I should clarify that I'm not saying he should break each tiny step into it's own Try/Catch. I am saying that it should be closer to wrapping each step that makes up a transaction.
For instance, depending on the situation and granularity of the error handling in the requirements, wrapping creating and opening a connection object and running a query and returning a result set is probably going to be more "friendly" than wrapping each step in that same code. If you're going after a generic DAL library that executes arbitrary SQL on a database, then you might want to wrap each of those steps. It just depends on the flexibility or importance of the transaction in question.
Some transactions are tolerant of a single item failure and continue on. Others need to know so they can stop at a certain point. And still others need to backout in the event of a certain set of failures, but can continue on in the event of a smaller failure.
I've probably done a piss-poor job of explaining this. I apologize in advance. It's late in the day and I'm starting to fall asl.....
|
|
|
|
|
Dave Kreskowiak wrote: I've probably done a piss-poor job of explaining this
If so, you have amply rectified it.
Dave Kreskowiak wrote: It's late in the day
That's all relative.
Gnite.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Very good points there, Luc.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Does an exception give any information more specific than the method in which it occurs and the exception type and message? If you have a long method it is sometimes hard to see where the error is.
Thanks!
|
|
|
|
|
Hi,
an Exception holds a lot of information:
- the Message (a one-line string)
- extra information (such as the file path on a file I/O error)
- the Stack TraceBack containing a list of methods, with line numbers when available
- and the same for any inner exception.
To get it all you need to use ToString(). Just looking at Message won't help much.
To locate the problem line, use a debug build and look at the very first line number
that appears in the stack traceback.
BTW: you can teach Visual to always show line numbers in the editor, see Tools/Options/
TextEditor/...
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|