Solved

Convert negative output in 2010 VB.net

Posted on 2015-01-15
8
119 Views
Last Modified: 2015-01-16
I am trying to import using 2010 VB.net and SQL 2008 R2 to text file but for a negative numbers it defaults to positive as an output when imported.

I have been trying to search but no luck.

2010 VB.net:


 lsTotalPrice = CStr(System.Math.Abs((System.Math.Round(lnTotalPrice, 2)))) 

Open in new window


Example:
SQL Table column is

Total Price:
-105.10(Negative)

Text file:
It displays as output is
105.10(Positive)


Any help is much appreciated.

Thank you.
0
Comment
Question by:Queennie L
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 40552186
The ABS command will change it from negative to positive.  Remove the ABS and you should be okay.

lsTotalPrice = CStr(System.Math.(System.Math.Round(lnTotalPrice, 2)))
0
 

Author Comment

by:Queennie L
ID: 40552199
There is an error when I remove the ABS.

It says "Identifier expected".

Thank you.
0
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 40552210
Yeah, sorry:

lsTotalPrice = CStr(System.Math.Round(lnTotalPrice, 2))
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:Queennie L
ID: 40552335
It's still not working.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 40552373
In what way is it not working?  The "Identifier expected" problem should be resolved...
0
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 40552628
Try this
lsTotalPrice=CStr( (System.Math.Round(lnTotalPrice, 2)))
0
 

Author Closing Comment

by:Queennie L
ID: 40553299
@Paulmacd:

You are right. It was my end.

Thank you for your help.
0
 
LVL 34

Expert Comment

by:Paul MacDonald
ID: 40553403
Happy to help.  Thanks for the points!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

740 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