• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

Currency Format

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 system.windows.forms.dll

Any help?
0
rabledsoe
Asked:
rabledsoe
1 Solution
 
LacutahCommented:
SelfPayAmt is a string, you may want to convert it to a decimal (single / double) first.
0
 
iboutchkineCommented:
Me.TextBox1.Text = Format(CDec(Me.TextBox1.Text), "C")
0
 
DabasCommented:
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.

Dabas
0
 
rabledsoeAuthor Commented:
That does it. Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now