?
Solved

How to convert nvarchar to money data format

Posted on 2009-02-18
11
Medium Priority
?
236 Views
Last Modified: 2012-05-06
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?
0
Comment
Question by:JessyRobinson1234
11 Comments
 
LVL 12

Expert Comment

by:CB_Thirumalai
ID: 23670599
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
 
LVL 8

Expert Comment

by:brittonv
ID: 23670607
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 23670618
Did you take a look at the format-function ?

dim yourValue as integer = 104978
dim str as string = string.Format("{0:c}", yourValue );
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Accepted Solution

by:
RobertNZana earned 1500 total points
ID: 23670671
check formatcurrency too
0
 

Author Comment

by:JessyRobinson1234
ID: 23670835
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
 
LVL 53

Expert Comment

by:Dhaest
ID: 23670956
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
 

Author Comment

by:JessyRobinson1234
ID: 23671006
Yes and also txtSupRev
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 23671018
Why would you format Me.txtSupRev.Text ?
It will be summed into the variable lblActualGrossRevenue (or I see it incorrectly)
0
 

Author Comment

by:JessyRobinson1234
ID: 23671399
what if I type in 200000 in txtSupRev can I format the number to 200,000.00 after postback?
0
 

Author Comment

by:JessyRobinson1234
ID: 23672708
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
 

Author Comment

by:JessyRobinson1234
ID: 23672833
I had no value in the first field, therefore the error.It worked fine with value.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.
Suggested Courses

864 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