Solved

check if string contains all numeric data

Posted on 2006-07-07
1
446 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 75 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now