Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

check if string contains all numeric data

Posted on 2006-07-07
1
Medium Priority
?
464 Views
Last Modified: 2010-05-18
I'm sure this is very easy to do, I need to check if a string to see if it only contains numbers I was wondering if there was a built in function for something like this.  Also is there a built in function to search a string for a particular character.
0
Comment
Question by:ICPooreman
1 Comment
 
LVL 17

Accepted Solution

by:
geobul earned 300 total points
ID: 17058236
Hi,

About your second question see Pos function:

i := Pos('x', StrVar);

About the first one:

function IsNumeric(const s: string): boolean;
var i: integer;
begin
  result := false;
  for i := 1 to Length(s) do begin
    if not (s[i] in ['0'..'9']) then exit;
  end;
  result := true;
end;

// usage:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if IsNumeric(Edit1.Text) then ShowMessage('OK');
end;

Regards, Geo
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
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

782 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