Public Class Form1
Public FinalStr As String
Private Sub HomeFtBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles HomeFtBox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub LandFtBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles LandFtBox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub YearBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles YearBox.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
Private Sub ExitButt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButt.Click
Me.Close()
End Sub
Private Sub ClearButt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButt.Click
NameBox.Clear()
AddressBox.Clear()
HomeFtBox.Clear()
LandFtBox.Clear()
YearBox.Clear()
TaxHomeBox.Clear()
TaxLandBox.Clear()
HomeDiscBox.Clear()
LandDiscBox.Clear()
TotalBox.Clear()
End Sub
Private Sub NameBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles NameBox.LostFocus
ToProper(NameBox.Text)
NameBox.Text = FinalStr
End Sub
Private Sub AddressBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddressBox.LostFocus
ToProper(AddressBox.Text)
AddressBox.Text = FinalStr
End Sub
Private Sub HomeFtBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles HomeFtBox.LostFocus
If Val(HomeFtBox.Text) < 0 Then
HomeFtBox.Clear()
HomeFtBox.Focus()
ChgFocus()
End If
End Sub
Private Sub LandFtBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles LandFtBox.LostFocus
If Val(LandFtBox.Text) < 0 Then
LandFtBox.Clear()
LandFtBox.Focus()
ChgFocus()
End If
End Sub
Private Sub YearBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles YearBox.LostFocus
If Val(YearBox.Text) < 0 Then
YearBox.Clear()
YearBox.Focus()
ChgFocus()
End If
End Sub
Public Sub ChgFocus()
MsgBox("You must enter a Posative Value for this field", 64, "Invalid Number")
End Sub
Public Shared Function ToProper(ByVal Str As String) As String
Dim OutStr = String.Empty
Dim Words() As String = Split(Str, " ")
For A = 0 To Words.GetUpperBound(0)
Dim TempWord As String = Words(A)
For B = 0 To TempWord.Length - 1
If B = 0 Then
OutStr += Char.ToUpper(TempWord(B))
Else
OutStr += Char.ToLower(TempWord(B))
End If
If A <> Words.GetUpperBound(0) And B = TempWord.Length - 1 Then
OutStr += " "
End If
Next
Next
FinalStr = OutStr
End Function
End Class