D
Dave griffiths
Hi all
Using VB2005 on Vista with a Norwegian locale setup.
The test program has 3 textboxes the sum held in txt3.
Using the code below, txt2 conversion causes an error when it is left
empty. The code in txt1 works OK but I am asking is there a better way
of coding this
Public Class Main
Dim y As Integer
Dim x As Integer
Private Sub txt1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txt1.LostFocus
If txt1.Text = "" Then
y = 0
Else
y = CInt(txt1.Text)
End If
End Sub
Private Sub txt2_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txt2.LostFocus
' This produces an error if txt2 is empty
x = CInt(txt2.Text)
txt3.Text = x + y
End Sub
End Class
Thanks in advance.
Using VB2005 on Vista with a Norwegian locale setup.
The test program has 3 textboxes the sum held in txt3.
Using the code below, txt2 conversion causes an error when it is left
empty. The code in txt1 works OK but I am asking is there a better way
of coding this
Public Class Main
Dim y As Integer
Dim x As Integer
Private Sub txt1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txt1.LostFocus
If txt1.Text = "" Then
y = 0
Else
y = CInt(txt1.Text)
End If
End Sub
Private Sub txt2_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txt2.LostFocus
' This produces an error if txt2 is empty
x = CInt(txt2.Text)
txt3.Text = x + y
End Sub
End Class
Thanks in advance.