Results 1 to 2 of 2

Thread: Display currency fields

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2002
    Location
    Colorado
    Posts
    23

    Display currency fields

    I have a some textboxes on a form in which the user will enter some numbers. These values correspond to dollar amounts, which I want the user to see, so I put the following code in the textchange event:
    VB Code:
    1. txtTextbox1.text = FormatCurrency(txtTextbox1.text)
    This works fine. It formats it just the way I want with the $ and everything.
    The problem is that when I want to use the value in that textbox for a calculation, I have to use the following code:
    VB Code:
    1. txtTotal = FormatCurrency(Val(Mid(txtTextbox1.Text, 2)) + Val(Mid(txtTextbox2.Text, 2)))
    I have to use the Mid function just to get the "$" off the front so that it will add correctly. Is there an easier way to do this? I thought of using the Masked Edit Control, but I haven't figured out how to get that as an option in VB.NET. But even if I did, I don't know if it is the best way to solve my problem. Any ideas?

    Thanks from this .Net newbie.
    LDD
    ----------------
    "Character is what you do in the dark." Dwight L. Moody

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    wouldn't you just say dim Mytotal as decimal = CDec(Textbox1.text)????

Posting Permissions

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



Click Here to Expand Forum to Full Width