How to convert nvarchar to money data format

I have a label that displays a budget number:

<asp:Label runat="server" ID="lblActualTransRevenue" CssClass="form" ></asp:Label>

the label is getting its value from here"

 Private Sub txtSupRev_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtSupRev.TextChanged

        If txtSupRev.Text.Length > 0 Then
            Me.lblActualGrossRevenue.Text = CInt(Me.lblActualTransRevenue.Text) + CInt(Me.txtSupRev.Text)
        Else
            Me.lblActualGrossRevenue.Text = ""
        End If
    End Sub

How do I display 104978 to 104,978?
JessyRobinson1234Asked:
Who is Participating?
 
RobertNZanaCommented:
check formatcurrency too
0
 
CB_ThirumalaiCommented:
I thought you got this resolved in the other post.  Has it not got resolved?  Can you try this link?
http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23158716.html
0
 
brittonvCommented:
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DhaestCommented:
Did you take a look at the format-function ?

dim yourValue as integer = 104978
dim str as string = string.Format("{0:c}", yourValue );
0
 
JessyRobinson1234Author Commented:
Hod do I mingle this in with my code:

Dim numInfo As Double = 23345D
        Dim result As String = numInfo.ToString("C")
        Response.Write(result.Substring(0, result.IndexOf(".")))

Private Sub txtSupRev_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtSupRev.TextChanged

        If txtSupRev.Text.Length > 0 Then
            Me.lblActualGrossRevenue.Text = CInt(Me.lblActualTransRevenue.Text) + CInt(Me.txtSupRev.Text)
        Else
            Me.lblActualGrossRevenue.Text = ""
        End If
    End Sub
0
 
DhaestCommented:
Do you mean that Me.lblActualGrossRevenue.Text must be formatted ?
Private Sub txtSupRev_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtSupRev.TextChanged
 
        If txtSupRev.Text.Length > 0 Then
            Me.lblActualGrossRevenue.Text = (CInt(Me.lblActualTransRevenue.Text) + CInt(Me.txtSupRev.Text)).ToString("C")
        Else
            Me.lblActualGrossRevenue.Text = ""
        End If
    End Sub

Open in new window

0
 
JessyRobinson1234Author Commented:
Yes and also txtSupRev
0
 
DhaestCommented:
Why would you format Me.txtSupRev.Text ?
It will be summed into the variable lblActualGrossRevenue (or I see it incorrectly)
0
 
JessyRobinson1234Author Commented:
what if I type in 200000 in txtSupRev can I format the number to 200,000.00 after postback?
0
 
JessyRobinson1234Author Commented:
Conversion from string "" to type 'Integer' is not valid when I run :

 Private Sub txtACOS_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtACOS.TextChanged

        If txtACOS.Text.Length > 0 Then
            Me.lblActualNetRev.Text = FormatCurrency(CInt(Me.lblAGR.Text) - CInt(Me.txtACOS.Text))
        Else
            Me.lblActualNetRev.Text = ""
        End If
    End Sub
0
 
JessyRobinson1234Author Commented:
I had no value in the first field, therefore the error.It worked fine with value.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.