Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Jul 2005
    Location
    Minneapolis, Minnesota, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Initial cap in text to number conversion (Word 2000/XP)

    In a dialog box, I have the user type a number. In the code, I have the following which converts the number to text. However, I need to have the text line start with a capital letter.

    Any ideas?

    Thanks

    Selection.TypeText Text:=(NumberToText(txtPar2.Text, "dollars", "/100", " and 00/100"))

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Initial cap in text to number conversion (Word 2000/XP)

    You can use something like this:

    Dim strText As String
    strText = NumberToText(txtPar2.Text, "dollars", "/100", " and 00/100")
    Selection.TypeText Text:=UCase(Left(strText, 1)) & Mid(strText, 2)

  3. #3
    New Lounger
    Join Date
    Jul 2005
    Location
    Minneapolis, Minnesota, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Initial cap in text to number conversion (Word 2000/XP)

    Thanks much -- that worked perfectly.

    Is there any way to code this so that if the number is more than one, it says Dollars and if it's 1.00 it says Dollar?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Initial cap in text to number conversion (Word 2000/XP)

    You'd have to modify the code of the NumberToText function. I cannot give specific advice without knowing what the code looks like - you haven't told us anything about it.

  5. #5
    New Lounger
    Join Date
    Jul 2005
    Location
    Minneapolis, Minnesota, USA
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Initial cap in text to number conversion (Word 2000/XP)

    The function code is:

    Code moved to attachment by HansV because it is very long (over 4,700 characters)

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Initial cap in text to number conversion (Word 2000/XP)

    I have attached a modified version of NumberToText. You must now omit the "s" from "dollars" when calling it, it will be added as needed. For example:

    strText = NumberToText(txtPar2.Text, "dollar", "/100", " and 00/100")

    Note: the HundredsToText function is not included, it is unchanged.

Posting Permissions

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