Results 1 to 4 of 4

Thread: Expert advise needed on text formating

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2005
    Posts
    43

    Expert advise needed on text formating

    Experience data input integrity through bad operator input. Need to force proper input to database as it is also used in reports were formatting is important.

    Currently use following which works fine:

    txtCity.Text = StrConv(txtCity.Text, vbProperCase) this format port elizabeth to Port Elizabeth
    txtCustomerCode.Text = Format(CustomerCode.Text, "00000") this format 12 to 00012
    txtemail.Text = lCase(txtemail.Text) this format [email protected] to [email protected]
    txtCountryCode.Text = UCase(txtCountryCode.Text) this format gpa to GPA
    txtCarrier.Text = UCase(Mid(txtCarrier.Text, 1, 1)) + LCase(Mid(txtCarrier.Text, 2)) this format GAUTENG GP to Gauteng gp

    now the experts please help with

    How do I get only the first character to uppercase (example above GAUTENG GP) but following uppercase to stay intact)
    like how to format GAuTENG GP to Gauteng GP


    South African funny names like:
    Dries van Zyl John van der Merwe (van der von du) as part of the surname but stay lower case

    how do I get input like:
    JOHN VAN DER MERWE to convert to John van der Merwe and dries van zyl to Dries van Zyl ( van der as lower case)

    How do I get input like need help. expert advise please. To Need help. Expert advise please (in other words uppercase at start of sentence and after the .)

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Expert advise needed on text formating

    There's no sense in trying to make the application intelligent... you can only go so far before you reach a brick wall.

    If they are so particular with the output of the result (obsessive compulsive bosses ^^) then they should hire someone to screen the DB data on a regular basis and make the necessary corrections. StrComp(..., ..., vbTextCompare) can be used to ensure that the data wasn't changed, just the case of the characters. Database design then becomes important... so that changes can be facilitated and propagated easily (say through references instead of having multiple copies of the same text).

    You might also want to consider using a static list of zip codes, country codes, cities, etc in the database (since these rarely change). The data entry can then be through dropdown lists intead of typed inputs.

    If the number of carriers is small and the list hardly changes then you could also make these dropdown; the list obtained from a DB table.

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Expert advise needed on text formating

    VB Code:
    1. Const TEST_DATA = "GAuTENG"
    2.    
    3.     MsgBox Left$(TEST_DATA, 1) & LCase(Mid$(TEST_DATA, 2))

    VB Code:
    1. Const TEST_DATA = "dries van der zyl"
    2.     Dim strTemp As String
    3.     Dim intPos As Integer
    4.    
    5.     strTemp = StrConv(TEST_DATA, vbProperCase)
    6.     intPos = InStr(UCase(strTemp), "VAN ")
    7.     If intPos > 0 Then
    8.         strTemp = Left$(strTemp, intPos - 1) & LCase(Mid$(strTemp, intPos, 1)) & Mid$(strTemp, intPos + 1)
    9.     End If
    10.     intPos = 0
    11.     intPos = InStr(UCase(strTemp), "DER ")
    12.     If intPos > 0 Then
    13.         strTemp = Left$(strTemp, intPos - 1) & LCase(Mid$(strTemp, intPos, 1)) & Mid$(strTemp, intPos + 1)
    14.     End If
    15.    
    16.     MsgBox strTemp

  4. #4
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657

    Re: Expert advise needed on text formating

    Marty has provided good code to handle proper case in general as well as examples for specific situations. leinad31 has a good point in having as much of the data entry from drop-down lists as possible.
    For the free text stuff, the only additional suggestion I can make is, if feasible, to create a database table of exceptions which would consist of the verbiage and a corresponding code (e.g. "U" for uppercase, "L" for lowercase, etc.), which you could implement during validation. This would only make sense if you could identify a manageable number of exceptions you would be most likely to encoutner (it would obviously be impractical if not impossible to store every conceivable name).
    "It's cold gin time again ..."

    Check out my website here.

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