Solved

Convert negative output in 2010 VB.net

Posted on 2015-01-15
8
122 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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 81

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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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

751 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