delphi4arab منتديات دلفي للعرب
كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15)
+--- الموضوع : كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف (/showthread.php?tid=9510)



كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - محمودد - 11-06-2018

السلام عليكم
كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف


RE: كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - Agmcz - 11-06-2018

وعليكم السلام
هكذا
PHP كود :
if s <> '' then
// يحتوي على حروف
أو
if Length(s) > 0 then
// يحتوي على حروف 



RE: كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - محمودد - 11-06-2018

(11-06-2018, 05:53 AM)Agmcz كتب : وعليكم السلام
هكذا
PHP كود :
if s <> '' then
// يحتوي على حروف
أو
if Length(s) > 0 then
// يحتوي على حروف 

هكذا يتحقق اذا كان السترنغ فارغ ام لا
المطلوب هو اذا كان يحتوي حروف عربي وليس ارقام


RE: كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - AX302 - 11-06-2018

PHP كود :
procedure TForm1.Button1Click(Sender: TObject);
const
 
 AUCTable: array [0 .. 49] of Word = ($0621, $0622, $0623, $0624, $0625, $0626,
 
   $0627, $0628, $0629, $062A, $062B, $062C, $062D, $062E, $062F, $0630, $0631,
 
   $0632, $0633, $0634, $0635, $0636, $0637, $0638, $0639, $063A, $063B, $063C,
 
   $063D, $063E, $063F, $0640, $0641, $0642, $0643, $0644, $0645, $0646, $0647,
 
   $0648, $0649, $064A, $064B, $064C, $064D, $064E, $064F, $0650,
 
   $0651, $0652);
var
 
 i: integer;
 
 Str: String;
begin
  Str 
:= 'dfg تجريب dfg4df4gd44 dfg';
 
 for i := Low(AUCTable) to High(AUCTable) do
 
 begin
    if Pos
(WideChar(AUCTable[i]), Str) > 0 then
    begin
      ShowMessage
('Arabic letters detected :)');
 
     Break;
 
   end;
 
 end;
end; 

جدول اليونيكود ماخود من موضوع Agmcz من هنا 
PHP كود :
http://delphi4arab.net/forum/showthread.php?tid=9475 



RE: كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - محمودد - 11-06-2018

(11-06-2018, 07:24 PM)AX302 كتب :
PHP كود :
procedure TForm1.Button1Click(Sender: TObject);
const
 
 AUCTable: array [0 .. 49] of Word = ($0621, $0622, $0623, $0624, $0625, $0626,
 
   $0627, $0628, $0629, $062A, $062B, $062C, $062D, $062E, $062F, $0630, $0631,
 
   $0632, $0633, $0634, $0635, $0636, $0637, $0638, $0639, $063A, $063B, $063C,
 
   $063D, $063E, $063F, $0640, $0641, $0642, $0643, $0644, $0645, $0646, $0647,
 
   $0648, $0649, $064A, $064B, $064C, $064D, $064E, $064F, $0650,
 
   $0651, $0652);
var
 
 i: integer;
 
 Str: String;
begin
  Str 
:= 'dfg تجريب dfg4df4gd44 dfg';
 
 for i := Low(AUCTable) to High(AUCTable) do
 
 begin
    if Pos
(WideChar(AUCTable[i]), Str) > 0 then
    begin
      ShowMessage
('Arabic letters detected :)');
 
     Break;
 
   end;
 
 end;
end; 

جدول اليونيكود ماخود من موضوع Agmcz من هنا 
PHP كود :
http://delphi4arab.net/forum/showthread.php?tid=9475 

توضيح اكتر اذا كان السترنغ يحتوي رقم لايتم التنفيد واذا كان يحتوي حروف يتم تنفيذ الشرط هذا المطلوب


RE: كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - ferrero - 11-06-2018

تحقق من انه يحتوي فقط على ارقام

function CheckNumber(const s: string): Boolean;
begin
  Result := True;
  try
    StrToInt(s);
  except
    Result := False;
  end;
end;


RE: كيف يمكن التحقق من السترنغ اذا كان يحتوي حروف - Delphi4Us - 12-06-2018

PHP كود :
var
 
 s: String;
 
 iValue, iCode: Integer;
...
val(s, iValue, iCode);
if 
iCode = 0 then
  ShowMessage
('s has a number')
else
 
 ShowMessage('s has not a number'); 

PHP كود :
function TryDecimalStrToInt( const S: string; out Value: Integer): Boolean;
begin
   result 
:= ( pos( '$', S ) = 0 ) and TryStrToInt( S, Value );
end; 

PHP كود :
function IsNumber(N : String) : Boolean;
var
I : Integer;
begin
Result 
:= True;
if 
Trim(N) = '' then
 
Exit(False);

if (
Length(Trim(N)) > 1) and (Trim(N)[1] = '0') then
Exit(False);

for 
I := 1 to Length(N) do
begin
 
if not (N[I] in ['0'..'9']) then
  begin
   Result 
:= False;
 
  Break;
 
end;
end;