Hi all,
I am making sure user input meets specific requirement to adhere to GAAP (Generally Acceptable Accounting Principals). I have coded something that works; however, I am wondering if there is a better way of doing this? In short, I have a MaskedTextBox that has a mask of 9-9999-9999. The five different GL account groups have specific guidelines to adhere to GAAP. I am working on Asset accounts right now. All account numbers based on GAAP start with the number one. I want to make sure this is adhered to in my app and if not, a messagebox comes up and then the first character is changed accordingly. Of course, this is working 1000%, but curious to see if there is a better way of doing this.
Code:Private Sub AccountNumberAsset_LostFocus(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles AccountNumberAsset.LostFocus With AccountNumberAsset .TextMaskFormat = MaskFormat.ExcludePromptAndLiterals Dim TheInput As String = .Text Dim TheChar As Char = TheInput.Substring(0, 1) If Not TheChar.ToString.Equals("1") Then If MessageBox.Show("Asset account numbers follow GAAP within " & My.Application.Info.ProductName & ". The first character has been changed to the number 1 to meet the GAAP standards.", _ "Invalid Account Number Start", _ MessageBoxButtons.OK, _ MessageBoxIcon.Exclamation, _ MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.OK Then .Focus() TheInput.Replace(TheChar, "1") End If End If End With




Reply With Quote