Solved

check if string contains all numeric data

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
ddeman not working in activex 3 93
Performance of SQL statement 37 97
Delphi: Connect to running MS Outlook 4 48
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…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

17 Experts available now in Live!

Get 1:1 Help Now