CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2001
    Location
    South Dakota
    Posts
    20

    Changing hard code

    I have an application that only accepts 7 digit ID numbers. I need it to accept 9 digits and 7 digits. The code is full of validation rules. I can get it to accept 9 by changing the 7s to 9s, but that doesn't help me. I need it to accept both. There are three areas in the code that I am hung up on.

    qd!pSiteNumber = Left(cmbSite, 7)
    Dim strSaveSiteNumber as String * 7
    qd!PSaveSiteNumber = Left$(Trim(cmbSite.text),7)

    Any suggestions would be GREATLY appreciated.
    Pat


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Changing hard code

    use a variable instead of a hard coded number.
    Replace the 7 with something like intIDLen then define intIDLEN like DIM intIDLEN as Integer.
    SOmeplace befopreprocessing, set intIDLEN to 7 or 9 depending on your needs at the time. The whole process looks something like this

    Dim strSaveSiteNumber as string
    Dim intIDLen as Integer

    If somecondition then
    intIDLen = 7
    else
    intIDLen = 9
    End If
    strSaveSiteNumber = mid$(strSaveSiteNumber, 1, intIDLen)
    qd!pSiteNumber = Left(cmbSite, intIDLen)
    qd!PSaveSiteNumber = Left$(Trim(cmbSite.Text), intIDLen)





    John G

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

Featured