Pieter Opublikowano 4 Września 2006 Opublikowano 4 Września 2006 Jak można sprawdzić czy kolor html napisany np w edit jest prawidłowy? Chodzi mi o delphi. Bo mam taki kod: function html2color(s:string):integer; begin result := strtoint('$00'+copy(s,6,2)+copy(s,4,2)+copy(s,2,2)); end; zamienia on standardowy string czyli np html na kolor. I chce żeby zwracał -1 jeżeli html jest błedny EDIT: Ups dałem złą funkcję. Poprawione... EDIT 2: dobra zrobiłem sobie sam :P function html2color(s:pchar):double; var a: string; res,i: integer; begin if not InStr('#',s) then s := pchar('#' + s); s := pchar(uppercase(s)); if length(s) > 7 then res := -1 else begin a := copy(s,6,2)+copy(s,4,2)+copy(s,2,2); for i := 1 to Length(a) do if not(a[i] in ['A'..'F', '0'..'9']) then begin res := -1; Exit; end else res := strtoint(pchar('$00'+a)); end; result := res; end;
Rekomendowane odpowiedzi
Jeśli chcesz dodać odpowiedź, zaloguj się lub zarejestruj nowe konto
Jedynie zarejestrowani użytkownicy mogą komentować zawartość tej strony.
Zarejestruj nowe konto
Załóż nowe konto. To bardzo proste!
Zarejestruj sięZaloguj się
Posiadasz już konto? Zaloguj się poniżej.
Zaloguj się