Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert negative output in 2010 VB.net

Posted on 2015-01-15
8
Medium Priority
?
128 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
  • 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 2000 total points
ID: 40552210
Yeah, sorry:

lsTotalPrice = CStr(System.Math.Round(lnTotalPrice, 2))
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 84

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

782 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