Autor Beitrag
PreMarT
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

Work: Win XP ; Home: Win Vista 64-Bit

BeitragVerfasst: Di 20.10.09 09:58 
Hallo alle zusammen,

Hab hier im Forum nacMasken gesucht aber leider nichts gefunden könnte mir villeicht jemand sagen wie ich folgende Maske realisiere?


TM/A3F (Wichtig ist das "/" das bekomm ich nciht hin)

und eventuell das die ersten beiden Zeichen nur Großbuchstaben und die letzten 3 Großbuchstaben oder Zahlen sein dürfen


ich danke im vorraus

MFG PMT


Moderiert von user profile iconNarses: Topic aus VisualCLX (Component Library for Cross Platform) verschoben am Mi 21.10.2009 um 22:32
Xion
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
EE-Maler
Beiträge: 1952
Erhaltene Danke: 128

Windows XP
Delphi (2005, SmartInspect), SQL, Lua, Java (Eclipse), C++ (Visual Studio 2010, Qt Creator), Python (Blender), Prolog (SWIProlog), Haskell (ghci)
BeitragVerfasst: Mi 21.10.09 20:15 
ööh...

wenn ich dich richtig verstehe:

Du packst ins OnKeyDown rein:

ausblenden 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:
procedure TForm1.LabeledEdit2KeyPress(Sender: TObject; var Key: Char);
begin
  if Key<>#8 then  //<< #8 ist Backspace
    begin
        if (Length(LabeledEdit2.Text)=0)and not (Key in ['A'..'Z']) then
          Key:=#0
        else if (Length(LabeledEdit2.Text)=1)and not (Key in ['A'..'Z']) then
          Key:=#0

        else if (Length(LabeledEdit2.Text)=2)and not (Key = '/') then
          Key:=#0

        else if (Length(LabeledEdit2.Text)=3)and not ( (Key in ['A'..'Z'])or(Key in ['0'..'9']) ) then
          Key:=#0
        else if (Length(LabeledEdit2.Text)=4)and not ( (Key in ['A'..'Z'])or(Key in ['0'..'9']) ) then
          Key:=#0
        else if (Length(LabeledEdit2.Text)=5)and not ( (Key in ['A'..'Z'])or(Key in ['0'..'9']) ) then
          Key:=#0

        else if (Length(LabeledEdit2.Text)>5) then
          Key:=#0;
    end;

end;


so würde ich das machen.

_________________
a broken heart is like a broken window - it'll never heal
In einem gut regierten Land ist Armut eine Schande, in einem schlecht regierten Reichtum. (Konfuzius)
PreMarT Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 57

Work: Win XP ; Home: Win Vista 64-Bit

BeitragVerfasst: Mo 26.10.09 09:29 
Ich danke dir schonmal für deine Mühe, das sieht echt gut aus, ich dachte da eher an sowas wie einen vergleich also quasi

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
If (edtEingabe = Form(xx/xxx)) then

mach was;

else
mach nix;

end;
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 26.10.09 14:24 
Hallo,

wenn das so eindeutig definiert ist:
- die ersten zwei Zeichen Großbuchstaben
- dann Trenner '/'
- danach weitere drei Zeichen Großbuchstaben oder Zahlen

... funktioniert ein direkter zeichenweiser Vergleich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
function CheckFormat(const s: String): Boolean;
var z : Integer;
const F_STR = 'AA/XXX';
begin
  Result := True;
  if Length(s) <> Length(F_STR) then
    Result := False
    else
    // jedes Zeichen von s mit Zeichen von F_STR vergleichen
    for z := 1 to Length(s) do
      begin
      case F_STR[z] of
        'A' : Result := s[z] in ['A'..'Z','Ä','Ü','Ö'];
        '/' : Result := s[z] = '/';
        'X' : Result := UpCase(s[z]) in ['A'..'Z','Ä','Ü','Ö','0'..'9'];
        end;
      if not Result then
        Break;
      end;
end;


Ist die Zeichenanzahl vor und hinter dem Trenner variabel muss halt bis zum Trenner und danach ab Trenner überprüft werden.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )