1. Public Class Form1
  2. Public FinalStr As String
  3.  
  4. Private Sub HomeFtBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles HomeFtBox.KeyPress
  5. If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
  6. e.Handled = True
  7. End If
  8. End Sub
  9.  
  10. Private Sub LandFtBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles LandFtBox.KeyPress
  11. If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
  12. e.Handled = True
  13. End If
  14. End Sub
  15.  
  16. Private Sub YearBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles YearBox.KeyPress
  17. If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." AndAlso e.KeyChar <> ControlChars.Back Then
  18. e.Handled = True
  19. End If
  20. End Sub
  21.  
  22. Private Sub ExitButt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButt.Click
  23. Me.Close()
  24. End Sub
  25.  
  26. Private Sub ClearButt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButt.Click
  27. NameBox.Clear()
  28. AddressBox.Clear()
  29. HomeFtBox.Clear()
  30. LandFtBox.Clear()
  31. YearBox.Clear()
  32. TaxHomeBox.Clear()
  33. TaxLandBox.Clear()
  34. HomeDiscBox.Clear()
  35. LandDiscBox.Clear()
  36. TotalBox.Clear()
  37. End Sub
  38.  
  39. Private Sub NameBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles NameBox.LostFocus
  40. ToProper(NameBox.Text)
  41. NameBox.Text = FinalStr
  42. End Sub
  43.  
  44. Private Sub AddressBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddressBox.LostFocus
  45. ToProper(AddressBox.Text)
  46. AddressBox.Text = FinalStr
  47. End Sub
  48.  
  49. Private Sub HomeFtBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles HomeFtBox.LostFocus
  50. If Val(HomeFtBox.Text) < 0 Then
  51. HomeFtBox.Clear()
  52. HomeFtBox.Focus()
  53. ChgFocus()
  54. End If
  55. End Sub
  56.  
  57. Private Sub LandFtBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles LandFtBox.LostFocus
  58. If Val(LandFtBox.Text) < 0 Then
  59. LandFtBox.Clear()
  60. LandFtBox.Focus()
  61. ChgFocus()
  62. End If
  63. End Sub
  64.  
  65. Private Sub YearBox_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles YearBox.LostFocus
  66. If Val(YearBox.Text) < 0 Then
  67. YearBox.Clear()
  68. YearBox.Focus()
  69. ChgFocus()
  70. End If
  71. End Sub
  72.  
  73. Public Sub ChgFocus()
  74. MsgBox("You must enter a Posative Value for this field", 64, "Invalid Number")
  75. End Sub
  76.  
  77. Public Shared Function ToProper(ByVal Str As String) As String
  78.  
  79. Dim OutStr = String.Empty
  80. Dim Words() As String = Split(Str, " ")
  81.  
  82. For A = 0 To Words.GetUpperBound(0)
  83. Dim TempWord As String = Words(A)
  84. For B = 0 To TempWord.Length - 1
  85. If B = 0 Then
  86. OutStr += Char.ToUpper(TempWord(B))
  87. Else
  88. OutStr += Char.ToLower(TempWord(B))
  89. End If
  90. If A <> Words.GetUpperBound(0) And B = TempWord.Length - 1 Then
  91. OutStr += " "
  92. End If
  93. Next
  94. Next
  95. FinalStr = OutStr
  96. End Function
  97. End Class