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
 
stifflersmom

Registriert seit: 8. Dez 2005
Ort: 24994 Holt
383 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#10

AW: "Sicheres" Umwandeln von Zeichenkette in Zahl

  Alt 29. Sep 2017, 15:06
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;
das werde ich gleich mal ausprobieren.
  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 13:27 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