try exception help

bahram

Member
Joined
May 1, 2006
Messages
13
Programming Experience
1-3
this is my code:

PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
tb1 = CType(Me.TextBox1.Text, Integer)
tb2 =
CType(Me.TextBox2.Text, Integer)
tb3 =
CType(Me.TextBox3.Text, Single)
Catch ex As Exception
MessageBox.Show(ex.Message)
EndTry
EndSub

i have 3 textbox and in this convert input to integer and single .
if my user input string value my try active and show a messagebox. now i want to know that wich one of my textboxs has this problem ? and input string in return for number inside textbox???
i need this in try and ex and those return wiche my textbox have this is problem ?

please help me ????
thanks
 
VB.NET:
Dim tb1, tb2 As Integer, tb3 As Single
If Not Integer.TryParse(TextBox1.Text, tb1) Then
    MsgBox("textbox1 failed")
End If
If Not Integer.TryParse(TextBox2.Text, tb2) Then
    MsgBox("textbox2 failed")
End If
If Not Single.TryParse(TextBox3.Text, tb3) Then
    MsgBox("textbox3 failed")
End If
You should also look into using ErrorProvider that will display error icon next to the textbox that doesn't validate, but the same datatype.TryParse method should be used.
 
thanks mu friend
please give a example for solving my problem ????
thanks
my friend i need to find in my try or in the cache ex .....
now i want to know that wich one of my textboxs has this problem ?
 
Back
Top