|
kowplunk wrote:
what is the benefit of handling exceptions of that sort at that point? Because right now all mine are being thrown to the global e catcher Is there any disadvantages that I am missing out on that will come to haunt me later?
Well, if the user attempts to open a file, it would be nice to catch the FileNotFoundException and the tell user to try again (or jump off a bridge ), or the SecurityException so we can tell the user he/she's got insufficient rights to open the file, or ...
It just depends on what the function does and what you want to do in the even of an exception. Production quality code is HEAVILY populated with exception handlers just because of the little things like trying to open a file that doesn't exist. You could encompass your app with one giant exception handler, but that would also mean that any error would effectively stop your app in its tracks and you would have to restart it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Blaiser wrote:
We use the thread exception handler to catch all "unanticipated" exceptions
Does this mean that you have the whole program running within one big t/c block?
|
|
|
|
|
kowplunk wrote:
Does this mean that you have the whole program running within one big t/c block?
Not really, but it does have that effect. I think of it as a last stop safety net; any errors that occur on the thread which are not otherwised handled get caught here.
Back in VB6, any production app worth its salt would have an error handler in every event routine because if an error occurs here, the app just croaks after VB gives its default error message.
But in .NET you can set an exception handler for the thread, and only write handlers for the errors you can do something about. Like Dave said, if the file a user selects does not exist, or is the wrong format, or they don't have the privs, I'll catch these, provide a specific message, perhaps log the occurance and move on. But if some other kind of error occurs that I don't anticipate, like "Index out of bounds" or "Object is Nothing" (i.e. a defect) then the global handler will catch this, log it, inform the user and give control back to the UI.
Now, as I said, we employ a good number of Try/Finally blocks through-out to be sure we release resources properly (close files, etc.), whether an error occurs or not. But the global handler has worked pretty well for us.
One last point, I would not loose too much sleep over the performance impact of having t/c blocks in your code. IMHO, excepting certain constructs (like tight loops), the impact is generally negligible relative to human response time in using the GUI. $0.02
A person with one watch knows what time it is; a person with two watches is never quite sure ...
[remove "NFS-" from email (No Freaking Spam)]
|
|
|
|
|
thanks for the info guys, it has definately helped.
|
|
|
|
|
Yes, this seems to be the recommended way to deal with exceptions according to a recent article. Was it at CP?
Kevin
|
|
|
|
|
Hi,
Could someone tell me if it is possible to reference an operator, such as "=" or "<" with a variable?
For example:
Dim Var1 as Interger
Dim VarRefOperator as ?????
Var1 = 10
VarRefOperator = "="
If Var1 VarOperator 10 Then ' If Var1 = 10
Msgbox("do something")
End If
Thanks,
weshill
|
|
|
|
|
There is no way to do that in VB.NET or any other of the 14 languages I'm familiar with. Frankly, I can't even think of a reason why you would want to do that... So, I'll ask, why would you want to do that?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know it seems silly. I was hoping to limit my coding.
This is what I am trying to do...
I have a combo box with (=, <, >, <>) operators in it and a piece of code that executes depending on the operator the user selects. Without the option to assign the operator a variable my coding become slightly longer with the use of a select statment that checks each possible option.
Thanks,
|
|
|
|
|
Unfortunately, that's what your going to have to do. Even if you were to make a class that did something like, internally, the class would have to check to see which operator was involved, then make the appropriate branch to do the comparison.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
We have a WinForms component in it's own assembly which is used in our .NET desktop app; the window is set by the app to be an MDI child in the app's MDI window.
The component can also be used by other .NET apps that set a ref to our library. Lastly, the component can also be used as a standalone window for apps do not wish an MDI child for its functions.
Is there any way to expose this .NET component so that a COM app (C++ or perhaps VB6) could use the component as an MDI child?
Thanks ... Blaiser
A person with one watch knows what time it is; a person with two watches is never quite sure ...
[remove "NFS-" from email (No Freaking Spam)]
|
|
|
|
|
Well, it's too much to go into in the Forums. I'll say that is should have been a desgin consideration before you even started to code this. Yeah, it's going to be that messy... ThNick Parker put together a great little article[^] that describes what needs to be done, complete with examples.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello VB Gurus!
I have got a very little problem here. I got "an invalid procedure call or argument" when I inserted this code on on the Form_Load procedure:
txtDescription.SetFocus
With this, I could not have the text object, txtDescription, focused on form start-up.
Please check.
Thanks,
dj41984
"All we need are ones like you"
|
|
|
|
|
I think you can't set focus in form load because the UI of the form is not completed its setup yet. If you want a certain control to have focus on display, try setting it's tab index to the lowest value among controls on the form that can receive focus.
A person with one watch knows what time it is; a person with two watches is never quite sure ...
[remove "NFS-" from email (No Freaking Spam)]
|
|
|
|
|
Blasier is right about the controls. You can't execute methods on the controls in the Form_Load event. You can either set the TabStop to 0 for that textbox or you could do the .SetFocus() method on Form_Activated. But, using the Activated event has it's drawbacks. If the user switches to another app, then back to yours, the Activated event will fire. Same thing if you .Show() or .ShowDialog() another form. The end result of this will be that the focus will alwyas return to the same control when the user goes back to your form.
The best method is to set the TabStop on that control to 0.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I got this code:
<br />
dim frm1 as new frmLogin<br />
dim frm2 as new frmMain<br />
sub main<br />
application.enablevisualstyles()<br />
frm1.showdialog()<br />
<br />
application.run(frm2)<br />
end sub<br />
It seems that the first form does not get the xp visual styles and the second form does. Is this a bug or is this expected? Can I ask why? Is there a work around? I need the first form to come before the second form so that I can configure the second form appropriately.
|
|
|
|
|
That's because you have the Application.EnableVisualStyles() in the wrong place. It should go before the Application.Run() for your main form, not inside it. The proper place for it in the Main function of your code. Just use Edit/Search and you'll find it. Also, put an Application.DoEvents() between the .EnableVisualStyles and the .Run for your app:
Sub Main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(new Form1())
End Sub
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,may i know is it possible to convert speech to text with vb.net?May i know where will have such source of code for reference?thanks!!!
|
|
|
|
|
There is not native supprot for it in the .NET BCL. You'll have to download and use the Speech SDK 5.1, here[^], or wait until the Speech.NET SDK is available. In either case, both will come with sample code. Although the SDK 5.1 will not be VB.NET specific, it can still be converted to VB.NET and used.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks!
By d way,may i know without Speech SDK 5.1,will i be able to develop text-to-speech and voice recognition program by using VB.NET?
From my research,i had get few sample program on text-to-speech.But when i try to develop same program,i found few component is not available like AxHTTSLib.Is it because i don't have d Speech SDK 5.1 software?
Thanks!!!!!;)
Thanks
|
|
|
|
|
MLSL wrote:
By d way,may i know without Speech SDK 5.1,will i be able to develop text-to-speech and voice recognition program by using VB.NET?
Not unless you want to develop your own Speech SDK from scratch. Good luck, you've got alot of research to do!
MLSL wrote:
From my research,i had get few sample program on text-to-speech.But when i try to develop same program,i found few component is not available like AxHTTSLib.Is it because i don't have d Speech SDK 5.1 software?
YES! You need the SDK in order to do this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Helo, how can I connect an application to a database (SQL server) that reside in site that need connected through internet?
Thanks
Learning .NET
|
|
|
|
|
Provided any firewalls in the way have the proper holes punched in them (ports opened up), you don't need to do anything special. Just include the complete Internet address of the server in your connection string. I don't think you would really want to expose an SQL server to the VERY HOSTILE environment known as the Internet, though!
A sample connection string:
Initial Catalog=MNFPool;User ID=MNFPoolUser;Password=MNFPoolUser;Data Source=mySQLserver.whateverdomain.com;
or you could use an IP address as the Data Source:
Initial Catalog=MNFPool;User ID=MNFPoolUser;Password=MNFPoolUser;Data Source=53.200.154.20;
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
I don't think you would really want to expose an SQL server to the VERY HOSTILE environment known as the Internet, though!
TO that end we've been using SQLXML / SOAP here - once you get your head around it, it's not too tricky to set up, but does have some limitations etc...
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
I am trying to use the use Mscomm32.ocx, but it gives me an exception stating that I don't have the liscense to use it, even after I use regsvr32 to register it. any thoughts?
|
|
|
|