Results 1 to 4 of 4

Thread: GAAP conformity. Better way of doing this?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    GAAP conformity. Better way of doing this?

    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

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,430

    Re: GAAP conformity. Better way of doing this?

    Firstly, as the documentation clearly states, you should not be handling the LostFocus event. If you want to be notified when a control loses focus then, as the documentation states, you handle the Leave event. That's not what you want though, because you don't want the control to lose focus if its contents is not valid. For that, you handle the Validating event. If validation fails then you set e.Cancel to True and the focus never leaves that control.

    Also, if you want to know whether the first character in a String is not something specific then you would more efficiently do it like this:
    Code:
    If myString(0) <> "1"c Then

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,945

    Re: GAAP conformity. Better way of doing this?

    If the first digit must be a 1 in the first place... why let them enter it? I'd put a label with "1-" in it, put it immediately to the left of the textbox, then set the format to "9999-9999" ... since it's clearly an asset account (judging by the name) it's going to be "1-" no matter what... so why have the hassle of letting the user muck it up? Just give them the parts they can change.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: GAAP conformity. Better way of doing this?

    Quote Originally Posted by techgnome View Post
    If the first digit must be a 1 in the first place... why let them enter it? I'd put a label with "1-" in it, put it immediately to the left of the textbox, then set the format to "9999-9999" ... since it's clearly an asset account (judging by the name) it's going to be "1-" no matter what... so why have the hassle of letting the user muck it up? Just give them the parts they can change.

    -tg
    I was thinking about that as I was going through it and this is what I decided to do. Sometimes I over think things and make them more complicated than they need to be.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width