Girilen bilginin sayısal,alfasayısal,tarih olma durumu
Forum kuralları
Forum kurallarını okuyup, uyunuz!
Forum kurallarını okuyup, uyunuz!
Girilen bilginin sayısal,alfasayısal,tarih olma durumu
edit içine girilen bilginin sayısal mı,alfasayısal mı, tarih mi olduğunu nasıl kontrol edebilirim
date tipinde, integer tipinde falan değişkenler tanımla.
edit'e girilen testi bu değişkenlere sırasıyla ata. (try except blokları içinde)
hata vermeyen blok sana edite girilen textin formatını verir.
gibi
edit'e girilen testi bu değişkenlere sırasıyla ata. (try except blokları içinde)
hata vermeyen blok sana edite girilen textin formatını verir.
Kod: Tümünü seç
deneme : date;
...
try begin deneme:=strtodate(edit1.text); end; except showmessage('bu bir tarih değil'); end;
Delphi syntax:
procedure Val(S; var V; var Code: Integer);
Description
In Delphi code, Val converts the string value S to its numeric representation, as if it were read from a text file with Read.
S is a string-type expression; it must be a sequence of characters that form a signed real number.
V is an integer-type or real-type variable. If V is an integer-type variable, S must form a whole number.
Code is a variable of type Integer.
If the string is invalid, the index of the offending character is stored in Code; otherwise, Code is set to zero. For a null-terminated string, the error position returned in Code is one larger than the actual zero-based index of the character in error.
Val performs range checking differently depending upon the setting of the $R compiler directive and the type of the parameter V.
Kod: Tümünü seç
var
v,i:integer;
s:string;
begin
s:='12345asd';
val(s,v,i);
ShowMessage(IntToStr(v)+' '+IntToStr(i));
end;
bu şekilde kullanıldığında v:string içindeki sayıyı veriyor (12345)
i ise sayı olmayan ilk karakterin indeksi yani 6 oluyor. i=0 ise sayı, değilse sayı değil.
Kolay Gelsin...
Bişnev in ney çün hikâyet mîküned
Ez cüdâyîhâ şikâyet mîküned

Ez cüdâyîhâ şikâyet mîküned
