LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-12-2005, 01:24 PM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
removing un-needed zeros from a number vb.net


I have an application that builds a string of numbers from a datagrid. the string will turn out to look something like this:

1234, 45.1250, 0.0899, 0.0135

Is there any way to remove the unneeded zero from the second number in the string. The zero may not always be in the same position.....it may look something like this 45.12560. Can anyone help me with this?
 
Old 09-12-2005, 02:44 PM   #2
tekkieman
Member
 
Registered: Dec 2004
Location: Northern CA
Distribution: Mepis 6.5
Posts: 123

Rep: Reputation: 15
You could try:

Code:
Double.Parse(string).ToString()
That will give you back a string with trailing zeroes trimmed. It will not trim the leading zeroes of course, since it must be a valid number for the fuction to work.




EDIT: forgot () on ToString

Last edited by tekkieman; 09-12-2005 at 02:49 PM.
 
Old 09-12-2005, 03:06 PM   #3
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I tried your suggestions and got an error saying :

Input string was not in the correct format

Do I need to add something else:

here is the code I use:

Code:
idRemovedStr = CompletedDataset.Tables("Table2").Rows(q).Item("Grade_Code") & "," & CompletedDataset.Tables("Table2").Rows(q).Item("Width") & "," & CompletedDataset.Tables("Table2").Rows(q).Item("Hot_Band_Gauge") & "," & CompletedDataset.Tables("Table2").Rows(q).Item("Target_Gauge")

Double.Parse(idRemovedStr).ToString()
 
Old 09-12-2005, 03:15 PM   #4
tekkieman
Member
 
Registered: Dec 2004
Location: Northern CA
Distribution: Mepis 6.5
Posts: 123

Rep: Reputation: 15
Here is mine. It was tested and works fine. Just change it to fit your project:

Code:
 Label1.Text = (Double.Parse(txtInput.Text).ToString())
 
Old 09-12-2005, 03:18 PM   #5
tekkieman
Member
 
Registered: Dec 2004
Location: Northern CA
Distribution: Mepis 6.5
Posts: 123

Rep: Reputation: 15
Sorry, just to clarify a little, this will need to be done for each string value you need to check, and returns only this single string value. That is, if your dataset contains three values, you will need to perform the function three times, adding each string to your comma separated string.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Keyboard Number Lock not working and a terminal emualtion program needed Peter M-M DamnSmallLinux 2 03-17-2005 08:04 AM
Help needed with Fedora Core 2 + WinXP after removing Mandrake 10 kainhart Fedora - Installation 4 07-05-2004 04:55 PM
Net monitoring tool needed Adony Linux - Software 2 06-30-2004 06:58 AM
Mandrake 9.2 net-install, vga mode number Quasaur Mandriva 2 11-25-2003 07:51 AM
ITEM = NUMBER is needed by (installed) PROGRAM mrPhantastik Linux - Software 1 08-27-2003 03:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration