+ Reply to Thread
Results 1 to 2 of 2

First String Character is the letter T or a number and remainder are numbers only

Hybrid View

  1. #1
    Registered User
    Join Date
    04-23-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    41

    First String Character is the letter T or a number and remainder are numbers only

    Hi,

    The problem with a textbox in a userform is as follows:

    1. The textbox represents an application number (no set number of characters) e.g. 12345678
    2. The textbox can only accept a "numeric only" value; however
    3. When the application is approved, the textbox can also accept an uppercase T as a prefix e.g. T12345678

    From my limited knowledge I believe I need to use something along the lines of either:

    a) Asc(Left(textbox, 1)) to extract the first character and check with an IF or CASE statement that it is either a number using Ascii or IsNumeric, or contains the letter "T" i.e. Ascii(84)
    If the first character is a letter other than an uppercase T or the remaining characters position 2 to N are not numeric should flag an error message.

    b) A checkbox when ticked would place an uppercase T into the textbox first character position however I would still need to check correct characters make up the rest of the application number.

    Would this be better handled on Exit or KeyPress?

    Any assistance would be great as to incorporating the "T" into a starting numeric only field. Thank you.

  2. #2
    Registered User
    Join Date
    04-23-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: First String Character is the letter T or a number and remainder are numbers only

    With a bit of perseverance I have managed to write the code and it works as intended. For those interested please see attached code.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 12
    Last Post: 03-20-2013, 05:46 PM
  2. Replies: 2
    Last Post: 08-23-2012, 04:58 PM
  3. Check if character is a letter or a number
    By duckboy1981 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-03-2009, 11:53 AM
  4. Replies: 2
    Last Post: 11-15-2006, 11:04 PM
  5. [SOLVED] Add character before 1st letter of string
    By al007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2005, 08:33 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1