Results 1 to 10 of 10

Thread: Letters uit een textbox in een array plaatsen?

  1. #1

    Letters uit een textbox in een array plaatsen?

    rij := EdtRomeins.text; < deze regel werkt uiteraard niet maar zo zou ik het wel willen hebben. Weet iemand hoe je de letters uit een editbox in een array zet? BvD!!



    Code:
    procedure TMainForm.EdtRomeinsChange(Sender: TObject);
    var uitkomst,i,AantalLetters : integer;
    rij : array of Char;
    begin
      Uitkomst := 0;
      Aantalletters := Length(EdtDecimaal.text);
      Setlength (rij,AantalLetters);
      rij := EdtRomeins.text;
      for i := 1 to AantalLetters do
        begin
          If rij[i] = 'M' then Uitkomst := Uitkomst + 1000;
          If rij[i] = 'D' then Uitkomst := Uitkomst + 500;
          If rij[i] = 'C' then Uitkomst := Uitkomst + 100;
          If rij[i] = 'L' then Uitkomst := Uitkomst + 50;
          If rij[i] = 'X' then Uitkomst := Uitkomst + 10;
          If rij[i] = 'V' then Uitkomst := Uitkomst + 5;
          If rij[i] = 'I' then Uitkomst := Uitkomst + 1;
          EdtDecimaal.text := IntToStr(Uitkomst);
    
        end;
    end;

  2. #2
    notice-itter SvG's Avatar
    Join Date
    Apr 2002
    Location
    's-Hertogenbosch
    Posts
    4,865
    Je kunt natuurlijk eenzelfde loop gebruiken om de EdtRomeins.text te doorlopen en 1-voor-1 in je array te zetten.. maar waarom de array gebruiken? misbruik die text property gewoon als array?
    !

  3. #3
    TCustomBuild Rob Bos's Avatar
    Join Date
    Jan 2003
    Location
    Eindhoven
    Posts
    4,213
    Een string is toch al een array ?

  4. #4
    een string is toch een array of char? Waarom gebruik/misbruik je dat niet?
    DeX 3 Delphi := The ease of VB with the power of C; Zoekt en gij zult vinden

  5. #5
    Hoe wil je die text dan 1 voor 1 in de array zetten?
    en wat bedoel je met misbruiken? Bedoel je dat ik bijv de 4e letter kan vergelijken met iets? Met wat voor code doe ik dat dan? BvD!!!

  6. #6
    notice-itter SvG's Avatar
    Join Date
    Apr 2002
    Location
    's-Hertogenbosch
    Posts
    4,865
    Code:
    var
      rij: string;
      uitkomst, i: integer;
    begin  
      rij := EdtRomeins.text;
      for i := 1 to length( rij ) do
      begin
        If rij[i] = 'M' then Uitkomst := Uitkomst + 1000;
        If rij[i] = 'D' then Uitkomst := Uitkomst + 500;
        If rij[i] = 'C' then Uitkomst := Uitkomst + 100;
        If rij[i] = 'L' then Uitkomst := Uitkomst + 50;
        If rij[i] = 'X' then Uitkomst := Uitkomst + 10;
        If rij[i] = 'V' then Uitkomst := Uitkomst + 5;
        If rij[i] = 'I' then Uitkomst := Uitkomst + 1;
      end;
      EdtDecimaal.text := IntToStr(Uitkomst);
    end;
    zoiets bedoel(en) ik/wij
    !

  7. #7
    met een loopje door de tekst lopen en teken per teken in een array zetten.
    Een string is een array of char, je kan ook tekst[1] opvragen net zoals bij een array
    DeX 3 Delphi := The ease of VB with the power of C; Zoekt en gij zult vinden

  8. #8
    Hartelijk dank!!!!

  9. #9
    Yay: Student(je) af
    Join Date
    Jun 2003
    Location
    Harderwijk
    Posts
    2,621
    En als je niet het wiel opnieuw uit wilt vinden, kan je zoiets als deze functie gebruiken, waarmee je - gecombineerd met de code uit je eerste post - van en naar romeinse cijfers kunt converteren.
    My software never contains bugs. Perhaps just undocumented features.

  10. #10
    Of dichter bij huis: Romeins trolletje
    DeX 3 Delphi := The ease of VB with the power of C; Zoekt en gij zult vinden

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. een probleem van een newbie
    By Marjan in forum Algemeen
    Replies: 3
    Last Post: 11-May-01, 22:37

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •