Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Capitalize letter after number

Posted on 2014-04-16
1
Medium Priority
?
406 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

730 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