Solved

Capitalize letter after number

Posted on 2014-04-16
1
401 Views
Last Modified: 2014-04-16
I have a text box and I would like any letter after a number to be capitalized. (123a Gold St -> 123A Gold St) after a user updates the data on the form.

Any suggestions with the best way to handel this in the VBA after update event?
0
Comment
Question by:thandel
1 Comment
 
LVL 1

Accepted Solution

by:
cctanaka earned 500 total points
ID: 40005743
I suggest to create a function to capitalize. Them call this function in the update event.
Let's say the textbox name is "txtdata"

then in the update event

txtdata.text = Capital_After_Numbers(txtdata.text)

--------------------

Function Capital_After_Numbers (texto as string) as string
Dim count as integer
Dim LastCharIsNumber  as boolean


Capital_After_Numbers = ""
LastCharIsNumber = false

For count = 1 to len (texto)

    if LastCharIsNumber then
        Capital_After_Numbers = Capital_After_Numbers & UCase(Mid(texto, count, 1))
    End If

    If asc(Mid(texto, count, 1))>= 48 And asc(Mid(texto, count, 1))<= 57  then
        LastCharIsNumber = True
    else
        LastCharIsNumber = False
    End If

next count

End Function
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question