locked
masked Text Box for Currency

    Question

  • I have a form that is linked to an access database. I am using the input masked for custom.  I set up the mask as follows:  Mask:   $ 9,999,999 
    Preview: $_,___,___.  The results are as follows:

    Database  3000000            Masked Field $ 3,000,000    This is ok
    Database  214000              Masked field $ 2,140,00_    Should be $ 214,000
    Database  61500                Masked field $ 6,150,0__    Should be $ 61,500

    I think the problem is the currency to text and am not sure of the best way to fix it .
    Can anyone put me on the right track?
    Saturday, January 09, 2010 1:55 AM

Answers

All replies

  • I have an example project that should help you.

    The example shows how to use a function to read the number and dynamically create a currency mask.  It is setup to let you type in a number manually in a textbox and it will show the mask and the number masked result.  You can modify it for the bound control.

    The link will take you to my site so you may want to right click it and open a new tab or window.

    Hope it helps

    http://www.srsoft.us/MemberProjects.aspx?mid=252&prjct=Dynamic_MaskedTextbox_Mask.zip
    • Marked as answer by sorokateam Saturday, January 09, 2010 11:58 PM
    Saturday, January 09, 2010 3:23 AM
  • The masked text box is set up to accept characters in that order from left to right.

    Instead, why don't you use currency formatting and copy it directly to a plain text box, something like this:

    Dim money As Decimal, smoney As String
    smoney = money.ToString("c")
    TextBox1.Text = smoney


    Solitaire
    Saturday, January 09, 2010 4:10 PM
  • You don't say how the textbox is "linked" to your database so this may not be appropriate but you could simply format the string with the same format string as your textbox mask.  Something like:

    MaskedTextBox1.Text = CInt(Table.Rows(0).Item(0)).ToString("0,000,000")

    • Marked as answer by sorokateam Sunday, January 10, 2010 12:01 AM
    Saturday, January 09, 2010 4:21 PM
  • Thanks for your prompt response, this is very helpful.

    Charlie
    • Marked as answer by sorokateam Sunday, January 10, 2010 12:01 AM
    Sunday, January 10, 2010 12:01 AM
  • Thanks for your prompt response, this is very helpful.

    Charlie
    • Marked as answer by sorokateam Sunday, January 10, 2010 12:01 AM
    Sunday, January 10, 2010 12:01 AM
  • Please do not mark your posts as the answer . Read the FAQ at the top of the page to see why and what marking posts is for . As a rule on this forum we do not mark our own posts we decide which post(s) provided the answer(s) to the question . Your response is not an answer to the question . That applies to proposing a post as the answer as well .
    coding for fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Please format the code in your posts with the button . Makes it easier to read .
    Sunday, January 10, 2010 12:18 AM