Solved

Convert negative output in 2010 VB.net

Posted on 2015-01-15
8
116 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 500 total points
ID: 40552210
Yeah, sorry:

lsTotalPrice = CStr(System.Math.Round(lnTotalPrice, 2))
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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 79

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IT Desktop Support 11 74
Query Optimization 14 44
Get the latest status 8 32
T-SQL:  Collapsing 9 25
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

778 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