AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

"Sicheres" Umwandeln von Zeichenkette in Zahl

Ein Thema von stifflersmom · begonnen am 29. Sep 2017 · letzter Beitrag vom 30. Sep 2017
 
Benutzerbild von Uwe Raabe
Uwe Raabe

Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.633 Beiträge
 
Delphi 12 Athens
 
#7

AW: "Sicheres" Umwandeln von Zeichenkette in Zahl

  Alt 29. Sep 2017, 10:30
Um meinen Vorschlag mal zu konkretisieren (hoffe mal, das geht alles unter D2006):
Delphi-Quellcode:
var
  AllFormatSettings: array of TFormatSettings;

procedure InitFormatSettings;
const
  cLocales: array[0..5] of Integer
      = (
         1031, { German }
         1033, { English }
         1040, { Italian }
         1055, { Turkish }
         3082, { Spanish }
         LOCALE_USER_DEFAULT);
var
  I: Integer;

begin
  SetLength(AllFormatSettings, Length(cLocales));
  for I := 0 to Length(cLocales) - 1 do begin
    GetLocaleFormatSettings(cLocales[I], AllFormatSettings[I]);
  end;
end;

function TryStrToFloatAll(const S: string; out Value: Double): Boolean;
var
  I: Integer;
begin
  Result := True;
  for I := 0 to Length(AllFormatSettings) - 1 do begin
    if TryStrToFloat(S, Value, AllFormatSettings[I]) then Exit;
  end;
  Result := False;
end;
Uwe Raabe
Certified Delphi Master Developer
Embarcadero MVP
Blog: The Art of Delphi Programming
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:21 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