PC Review


Reply
Thread Tools Rate Thread

Convert srting "(192)"

 
 
Robert Bravery
Guest
Posts: n/a
 
      22nd Jul 2006
HI all,

I have imported string data that contains numerical values. The negatives
are reporesented in round braces () as in (192) representing -192. How can I
convert thin string into a negative number while converting other numbers as
positive numerical data

Thanks
Robert


 
Reply With Quote
 
 
 
 
Greg Young
Guest
Posts: n/a
 
      22nd Jul 2006
using System.Globalization;

string num = "(192)";
int foo = int.Parse(num, NumberStyles.AllowParentheses);
Console.WriteLine(foo);

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung

"Robert Bravery" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI all,
>
> I have imported string data that contains numerical values. The negatives
> are reporesented in round braces () as in (192) representing -192. How can
> I
> convert thin string into a negative number while converting other numbers
> as
> positive numerical data
>
> Thanks
> Robert
>
>



 
Reply With Quote
 
Michael Nemtsev
Guest
Posts: n/a
 
      22nd Jul 2006
Hello Robert,

There are a lot of variations - regexp, checking "(" existence and etc
Smth like using String.Replace to replace the "(" on "-", remove "-" and
Convert.ToInt32(&lt;your_string&gt

RB> HI all,
RB>
RB> I have imported string data that contains numerical values. The
RB> negatives are reporesented in round braces () as in (192)
RB> representing -192. How can I convert thin string into a negative
RB> number while converting other numbers as positive numerical data
RB>
RB> Thanks
RB> Robert
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche


 
Reply With Quote
 
Robert Bravery
Guest
Posts: n/a
 
      22nd Jul 2006
Thanks All

Robert



"Robert Bravery" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> HI all,
>
> I have imported string data that contains numerical values. The negatives
> are reporesented in round braces () as in (192) representing -192. How can

I
> convert thin string into a negative number while converting other numbers

as
> positive numerical data
>
> Thanks
> Robert
>
>



 
Reply With Quote
 
Michael Nemtsev
Guest
Posts: n/a
 
      22nd Jul 2006
Hello Greg,

Gotcha! it catched from my mind

GY> using System.Globalization;
GY>
GY> string num = "(192)";
GY> int foo = int.Parse(num, NumberStyles.AllowParentheses);
GY> Console.WriteLine(foo);
GY> Cheers,
GY>
GY> Greg Young
GY> MVP - C#
GY> http://codebetter.com/blogs/gregyoung
GY> "Robert Bravery" <(E-Mail Removed)> wrote in message
GY> news:(E-Mail Removed)...
GY>
>> HI all,
>>
>> I have imported string data that contains numerical values. The
>> negatives
>> are reporesented in round braces () as in (192) representing -192.
>> How can
>> I
>> convert thin string into a negative number while converting other
>> numbers
>> as
>> positive numerical data
>> Thanks
>> Robert

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how i convert "100" to "hundred"( number to text) in excel-2007 mohanraj Microsoft Excel Worksheet Functions 1 11th May 2008 09:07 PM
Convert HD file system from "RAW" to "NTFS" on slave drive? (Win X =?Utf-8?B?RVhGRlBN?= Windows XP Help 1 6th Nov 2007 04:49 PM
Excel VBA to convert "dd.MM.yy" text to "dd/MM/yyyy" format date? =?Utf-8?B?UGF1bCBK?= Microsoft Excel Programming 4 11th Jul 2007 11:32 AM
LOTUS TRANSITION KEYS "/" "R" / "V" convert formulas to text. =?Utf-8?B?Ym9iQGdvcmRvbmVuZ2luZWVyaW5nLmNvbQ==?= Microsoft Access Getting Started 3 18th Jan 2006 09:15 AM
sending "works" email won't open.. needs "word"...can I convert =?Utf-8?B?d2hpdGVrbmlnaHRnb2xmbnV0?= Microsoft Access 1 28th Feb 2005 07:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 AM.