473,786 Members | 2,608 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert srting "(192)"

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
Jul 22 '06 #1
4 2005
using System.Globaliz ation;

string num = "(192)";
int foo = int.Parse(num, NumberStyles.Al lowParentheses) ;
Console.WriteLi ne(foo);

Cheers,

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

"Robert Bravery" <me@u.comwrot e in message
news:Ov******** ******@TK2MSFTN GP03.phx.gbl...
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


Jul 22 '06 #2
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_strin g&gt;)

RBHI all,
RB>
RBI have imported string data that contains numerical values. The
RBnegatives are reporesented in round braces () as in (192)
RBrepresenting -192. How can I convert thin string into a negative
RBnumber while converting other numbers as positive numerical data
RB>
RBThanks
RBRobert
---
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
Jul 22 '06 #3
Thanks All

Robert

"Robert Bravery" <me@u.comwrot e in message
news:Ov******** ******@TK2MSFTN GP03.phx.gbl...
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


Jul 22 '06 #4
Hello Greg,

Gotcha! it catched from my mind

GYusing System.Globaliz ation;
GY>
GYstring num = "(192)";
GYint foo = int.Parse(num, NumberStyles.Al lowParentheses) ;
GYConsole.Write Line(foo);
GYCheers,
GY>
GYGreg Young
GYMVP - C#
GYhttp://codebetter.com/blogs/gregyoung
GY"Robert Bravery" <me@u.comwrot e in message
GYnews:Ov****** ********@TK2MSF TNGP03.phx.gbl. ..
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 Nietzsche
Jul 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
11673
by: Chris Krasnichuk | last post by:
hello, Does anyone know how I make php work on "my" computer? I made a mistake in my last post so I fixed it here. Chris
2
3720
by: jissay | last post by:
Hi, I use the following scrit in an Intranet with the user name = "" and the password = "" : <?php $ftp_server = "192.168.25.25"; $ftp_user = ""; $ftp_pass = "";
1
6273
by: Ly | last post by:
Scenario: ---------- SQL server: 192.168.1.3 Server 2: 192.168.1.2, a folder named ABC is shared out. Both servers have the same password for the account named "Administrator" ----------
10
3730
by: mike | last post by:
regards: I use Jtidy (api) to translate a HTML file into a "XHTML file". But The "XHTML file" cannot be identified by nokia 6600. Do I miss something important? Or this is Jtidy's weakness or bug? Can someone excellent to tell me the reason. best wishes
1
1438
by: Edward King | last post by:
I have a statement in a asp,like follows£º var str=window.top.main.document.all.contenttext.value; I use IIS5.0 to deploy this asp,then I visit this asp like follows: http://localhost/test/default.asp I found I can get this page,then I use my computer's IP address, http://192.168.0.3/test/default.asp I got errors! It said "no right"£¬then I erase this statement,then I visit
2
30546
by: GRB | last post by:
A client wants me to decrypt a cookie. They encrypted the data in java using TripleDES. The key provided is a 168 bit 44 character key, DESede alogorithm. Ive tried to decrypt in vb.net and get the above error. Below is the class I use and the code I use to call it. Not sure wher I'm going wrong here. The TripleDES service provider only uses a 192 bit 24 character length key. Any help would be greatly appreciated.
4
2394
by: mcmreddy | last post by:
Hi! Is there a way to convert application id ( db2 list applications output) to a readable format?. Auth Id Application Appl. Application Id DB # of Name Handle Name Agents -------- -------------- ---------- ------------------------------ -------- ----- VBUILD JDBC4DB2 735 /1061212.3238.00010024001E
21
30544
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases (connected/disconnected), system call returns 0. Can someone please show what I am doing wrong? How to check the actual result of the ping status using C++ on Redhat linux ? Thanks in advance.
10
3204
by: =?Utf-8?B?TWF0dA==?= | last post by:
I am using the following code to connect to and download files from an ftp server, but the Symantec anti-virus software on some of my customers machines tells them that their computers are attacking the Ftp server with "FTP Pathname Glob BO". See the following link for more info: http://www.symantec.com/avcenter/attack_sigs/s20430.html This is standard .Net code, so I'm not understanding why it would trigger such a response. Also,...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.