![]() |
Gültiges Zeitformat
Wie kann ich überprüfen ob ein string ein gültiges zeitformat enthält?
z.b 14:30:20 oder auch nur 14:30 |
Re: Gültiges Zeitformat
Hi simonko,
versuch mal Dein Glück mit
Delphi-Quellcode:
Die Funktion verlangt eine Datums/Zeiteingabe liefert einen Fehler falls es nicht paßt.
StrToDate( s : String )
Niels |
Re: Gültiges Zeitformat
Hai simonko,
mit der Funktion von nieurig und einer Fehlerbehandlung könnte das dan so aussehen:
Delphi-Quellcode:
function CheckTimeString (aValue : String) : boolean;
begin try result := True; StrToTime(aValue); except result := False; end; end; procedure TForm1.btn_CheckTimeClick(Sender: TObject); begin if CheckTimeString(edt_Zeit.Text) then ShowMessage('okay'); end; |
Re: Gültiges Zeitformat
Zitat:
Delphi-Quellcode:
[edit]Der Hai war wieder schneller[/edit]
function IsTimeStringValid(TimeString : string) : boolean;
var ADateTime : TDateTime; begin result := true; try ADateTime := StrToDateTime(TimeString); except result := false; end; end; |
Re: Gültiges Zeitformat
danke für eure antworten.
|
Re: Gültiges Zeitformat
Zitat:
Delphi-Quellcode:
"Wenn nach Aufruf kein Fehler aufgetreten ist dann isses True sonst False"...
function CheckTimeString (aValue : String) : boolean;
begin try StrToTime(aValue); result := True; except result := False; end; end; Ausserdem greife ich genau einmal auf Result zu, du ein bis zweimal :stupid: |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:06 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz