Solved

Capitalize letter after number

Posted on 2014-04-16
1
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

710 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