[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

To trim a string value

Posted on 2004-10-13
3
Medium Priority
?
205 Views
Last Modified: 2010-04-01
Hi!

I have a string value that can look somewhat like this:
"410.13456"
"1024.7940"
or something like that.

What I want to do is, if there's a "." in the string, remove everything behind it. Ie. "410.13456" will become "410".

How do I do this the simplest way possible.

Regards,
David
0
Comment
Question by:larsan
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 1500 total points
ID: 12296308
int dot = s.indexOf(".");
if (dot!=-1)
{
   s = s.substring(0, dot-1);
}
0
 
LVL 92

Expert Comment

by:objects
ID: 12296313
or maybe:

s = s.split("\.")[0];
0
 

Author Comment

by:larsan
ID: 12296881
The first one works if you put it like this:

s=s.substring(0,dot);

Thanks!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Social messanging services like WhatsApp and Facebook can help businesses in ways that many owners don't even imagine, giving new opportunities to connect with customers. Discover some of the most innovative things they can do for your company.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month18 days, 18 hours left to enroll

834 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