Solved

# TryIntToStr and partial strings...

Posted on 2003-03-05
Medium Priority
1,377 Views
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
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
• 2

LVL 27

Expert Comment

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

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

ID: 8075599
That helps... thanks
0

## Featured Post

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