Currency Format

Posted on 2004-11-24
Last Modified: 2010-04-23
I am trying to format a text field as currency using the following code.

Private Sub TxtinsSelfPayAmt_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtinsSelfPayAmt.TextChanged
        Dim SelfPayAmt As String
        SelfPayAmt = TxtinsSelfPayAmt.Text
        TxtinsSelfPayAmt.Text = String.Format("{0:c})", SelfPayAmt)
    End Sub
When I run debug I get the following error.

An unhandled exception of type 'System.StackOverflowException' occurred in

Any help?
Question by:rabledsoe
    LVL 9

    Accepted Solution

    SelfPayAmt is a string, you may want to convert it to a decimal (single / double) first.
    LVL 28

    Expert Comment

    Me.TextBox1.Text = Format(CDec(Me.TextBox1.Text), "C")
    LVL 27

    Expert Comment

    Hi rabledsoe:
    >         SelfPayAmt = TxtinsSelfPayAmt.Text
    Try changing this line to
        SelfPayAmt = CDbl(TxtinsSelfPayAmt.Text)

    If that did not help, then try adding a Try.. Catch , and post the full ex.Message & vbcrl & ex.StackTrace here for further clues.


    Author Comment

    That does it. Thanks

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now