I 'm making a project, and i need to make it well, so i want to manage exceptions well
I mean to make a message for each error, and i want to write message in French not in English, so what I should do?
I need to check data types (int - string ...) because the user can add a float in a case of integer and a string where he should enter a number...
I need to check the date format because the user can use the US or the UK system dd-mm-yyyy or mm-dd-yyyy or else.
I need to manage the errors by the application like the division by zero and else.
'Write your code here
Catch ex as exception
from above code u can able to handle any type of exception.
Now call following function at keypress event of Textbox so the user must be enter proper value
// For accept only Text & white Space pass "e" ( one of the argument of keypress event) to this function
Public Sub CheckPressedKeyText(ByVal key As System.Windows.Forms.KeyPressEventArgs)
If Not (Char.IsControl(key.KeyChar) Or Char.IsLetter(key.KeyChar) Or Char.IsWhiteSpace(key.KeyChar)) Then
key.Handled = True
// For accept only numeric value with "." pass "e" ( one of the argument of keypress event) and "sender.text" to this function
Public Sub CheckPressedKeyNumericWithDot(ByVal key As System.Windows.Forms.KeyPressEventArgs, ByVal str As String)
If str.Contains(".") Then
If Not (Char.IsControl(key.KeyChar) Or Char.IsNumber(key.KeyChar) Or key.KeyChar = ".") Then
key.Handled = True
// For accept only numeric value without "." pass "e" ( one of the argument of keypress event) to this function
Public Sub CheckPressedKeyNumericWithoutDot(ByVal key As System.Windows.Forms.KeyPressEventArgs)
If Not (Char.IsControl(key.KeyChar) Or Char.IsNumber(key.KeyChar)) Then
key.Handled = True
for date, use DateTimePicker & set format property to "Custom" and then set Custom format property to ur choice.
thanks man ...
now if i used the try ... catch ex msg(ex.msg) end try
i can't specify the error
in meaning of: if a procedure does not exist in the DB ... or if we have division by zero how to specify my msg to show ...
i want to send the folowing msg :
1- if division by zero : msgbox("Tu as fait une division par zero")
2- if connection broken : msgbox(" il y a eu une coupure de connection")
u see ... i need to take in consideration some execptions
First of all, code that's wrapped in hundreds of try/catch statements is bad code. You should first check, for example, if you may be about to divide by zero. You should use int.tryparse,double.tryparse, etc, to see if a string contains the value type you expect. You should allow casting from double to int, unless you have special reasons not to.
An exception should be, well, exceptional. It shouldn't be something that you expect to happen in normal flow.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I want to get a reference to a control on a form given the form name and the
control name as strings. For example I want to set the enabled/visible
properties of say "mnuExit" control in "frmMain" at run time ("mnuExit" and
"frmMain" are strings retrieved from a database). GetObject function
doesn't seem to work saying "Cannot create ActiveX control". Is there a way
to do this?
I have a control called mnuExit in MenuStrip1 in FrmMain. When I try to iterate through the controls collection in FrmMain I only get reference to MenuStrip1 and not to the control mnuExit. However, when I work with the form in IDE I get reference to FrmMain.mnuExit. Is there a way to get reference to FrmMain.mnuExit through direct iteration?
You can Google for "error enumerating data servers"[^] (with the quote marks!) to start trouble shooting the problem. There's a bunch of possible causes, dependant on the database server you're trying to use and what's installed on your machine.
Dave Kreskowiak Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
Am redesigning the application that was written by other programmer who left the company.there is no documentation. am just looking at his and redisigning the application. the application has datagrid, i have change from Ms Access to Microsoft sql, when i run my new application checking on the datagrid result, this is what i get.
"Subscript out of range" and mark this Column yellow"
datagrid1.Columns(3).Width = 1820.
what would be the cause ?
and what should i have in mind while editing the datasource from access to Sql?
Actually i want read a line from 1st text file and search this line in the second text file( which had the string as in 1st txt file and equivalent localized string) and then copy this localized string from 2nd text file and replace with the 1st one.
Thanks in advance!
Last Visit: 31-Dec-99 18:00 Last Update: 20-Jun-21 16:23