Autor Beitrag
TimonWorld
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 29.05.04 12:32 
Hallo! Ich möchte in einem Edit die Buchstaben durch Zahlen ersetzen!

zB:

A = 1
B = 2
C = 3
T = 5

Tab = 125

Aber wie Programmiere ich das???

Gruß, Timon
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 29.05.04 12:39 
StringReplace?
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 29.05.04 12:58 
Und wie benutze ich StringReplace
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 29.05.04 13:11 
TimonWorld hat folgendes geschrieben:
Und wie benutze ich StringReplace

Steht in der Hilfe.

Oder soll das ganze gelich bei der Eingabe passieren? Du musst schon etwas genauer werden, sonst ist das hier nur ein Rumgerate.
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Sa 29.05.04 13:11 
Drück mal F1

[edit]Arghh, zu langsam :evil:[/edit]

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Sa 29.05.04 13:21 
Laut Profil arbeitet er mit D6 Pers und D3 Prof. Delphi 3 hat kein StringReplace, Delphi 6 schon. Jetzt muß er nur noch sagen mit welchem Delphi er arbeitet.

_________________
Gruß
Martin
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 29.05.04 13:35 
Mit D6 Personal ENGLISCH, d.h. Hilfe auch Englisch und ich hab er seit drei Jahren Englisch (bin jetzt in Klasse 7!)

ausblenden Quelltext
1:
2:
3:
4:
5:
StringReplace replaces occurrences of the substring specified by OldPattern with the substring specified by NewPattern. StringReplace assumes that the source string, specified by S, may contain Multibyte characters.

If the Flags parameter does not include rfReplaceAll, StringReplace only replaces the first occurrence of OldPattern in S. Otherwise, all instances of OldPattern are replaced by NewPattern.

If the Flags parameter includes rfIgnoreCase, The comparison operation is case insensitive.


Davon kapier ich fast garnichts!
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 29.05.04 13:37 
TimonWorld hat folgendes geschrieben:
Mit D6 Personal ENGLISCH, d.h. Hilfe auch Englisch und ich hab er seit drei Jahren Englisch (bin jetzt in Klasse 7!)


es gibt im Forum genug einträge, wie man zu d6P eine deutsche Hilfe bekommt.

dt. hilfe hat folgendes geschrieben:

type
TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;

Beschreibung

Mit StringReplace ersetzen Sie in dem angegebenen String den im Parameter OldPattern festgelegten Sub-String mit dem im Parameter NewPattern übergebenen neuen Sub-String. StringReplace nimmt an, daß der String Multibyte-Zeichen enthalten kann.

Wenn im Parameter Flags nicht rfReplaceAll enthalten ist, wird nur das erste Vorkommen von OldPattern im String S ersetzt. Andernfalls werden alle Instanzen von OldPattern durch NewPattern ersetzt.

Wenn der Parameter Flags rfIgnoreCase enthält, wird die Groß-/Kleinschreibung nicht berücksichtigt.


Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 29.05.04 14:19 
Aber wie genau soll ich das den jetzt anwenden?


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    //TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
    function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
    Image1: TImage;
    BitBtn1: TBitBtn;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var  umlaute : string;
begin
  umlaute:=edit1.Text;
  stringreplace(umlaute,'Ü','Ue');
  edit2.Text:=umlaute;
end;

end.
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 29.05.04 14:23 
Aber wie genau soll ich das den jetzt anwenden?


ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    //TReplaceFlags = set of (rfReplaceAll, rfIgnoreCase);
    function StringReplace(const S, OldPattern, NewPattern: string; Flags: TReplaceFlags): string;
    Image1: TImage;
    BitBtn1: TBitBtn;
    Edit1: TEdit;
    Edit2: TEdit;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.BitBtn1Click(Sender: TObject);
var  umlaute : string;
begin
  umlaute:=edit1.Text;
  stringreplace(umlaute,'Ü','Ue');
  edit2.Text:=umlaute;
end;

end.
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Sa 29.05.04 14:32 
Du mußt lernen die Hilfe selbst richtig deuten zu können, denn es gibt Funktionen die viel schwieriger sind. StringReplace ist sehr einfach:

ausblenden Delphi-Quelltext
1:
2:
Str := StringReplace('abcd cd ab cd ab cd', 
    'ab', 'gf', [rfReplaceAll, rfIgnoreCase]);


Hier wird "ab" gegen "gf" getauscht.

Wenn Flags rfReplaceAll enthalten ist, dann wird alles im Text ersetzt. Ohne den Flag word nur das erste gefundene Teil ersetzt.

Wenn Flag rfIgnoreCase enthalten ist, dann wird die Groß-/Kleinschreibung nicht berücksichtigt.

_________________
Gruß
Martin
TimonWorld Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Sa 29.05.04 22:25 
THX!

Die Hilfe hab ich einigermaßen verstanden, aber nicht was an 4. Steller in der Klammer kommt (String, Altertext, Neuertext, ???)! Ich habe die [ Eckklammern vergessen!

cya, timon