Solved

Convert negative output in 2010 VB.net

Posted on 2015-01-15
8
110 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 33

Expert Comment

by:paulmacd
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 33

Accepted Solution

by:
paulmacd earned 500 total points
ID: 40552210
Yeah, sorry:

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

Author Comment

by:Queennie L
ID: 40552335
It's still not working.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 33

Expert Comment

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

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 33

Expert Comment

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 …
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now