?
Solved

TryIntToStr and partial strings...

Posted on 2003-03-05
3
Medium Priority
?
1,377 Views
Last Modified: 2007-12-19
I need to find out if a string contains a number... and return the numeric part in one field and the string parts in (two) other fields.

The string may be along the lines of...

AAAA123456BBBBB or 123456AAAAAAA or AAAAAA123456.

What is the easiest way to pull out the number?
0
Comment
Question by:Morgans43
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8075351
function WhatEverName(var InputStr, Part2Str : String) : String;
begin
  Part2Str := '';
  result := '';
  for i := 1 to length(InputStr) do
    if inputstr[i] in ['0'..'9'] then
      result := result + inputstr[i]
  inputStr := copy(InputStr,1,length(result));
  Part2Str := copy(InputStr,Length(result),MaxLongInt);
end;

//usage sample
  edit3.Text := WhatEverName(Edit1.text,edit2.text);

whereas
edit3 holds the numberstring
edit1 holds then after call the charstr-part before, if there any
edit2 holds then after call the charstr-part after, if there any

just from scratch
not tested

meikl ;-)
 
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 150 total points
ID: 8075387
sorry one mistake in this line after review

inputStr := copy(InputStr,1,length(result));
 
should be

inputStr := copy(InputStr,1,pos(inputstr,result)-1);
 

maybe i have the pos parameter mixed
->pos(result,inputstr)
and the -1 is not needed

meikl ;-)
0
 

Author Comment

by:Morgans43
ID: 8075599
That helps... thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

743 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