IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 Delphi Discussion :

Convertir C# en Delphi


Sujet :

Delphi

  1. #1
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2016
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Janvier 2016
    Messages : 71
    Points : 19
    Points
    19
    Par défaut Convertir C# en Delphi
    Bonjour,
    je veux savoir svp comment convertir ce code en c# en delphi
    Cordialement,

    Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
    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
        void TextBox1TextChanged(object sender, EventArgs e)
        {
            StringBuilder key = new StringBuilder();
     
            // for each digit in the serial number:
            // 1. convert it to int and add 5, then convert it back to string
            // 2. if the length of result string is > 1, take the second digit else take the first one
            // 3. append that digit to the end of the key
     
            for (int i = 0; i < textBox1.Text.Length; i++)
            {                               
                string str2 = (Convert.ToInt32(textBox1.Text.Trim().Substring(i, 1)) + 5).ToString();
     
                if (str2.Length == 1)
                    key.Append(str2);
                else        
                    key.Append(str2.Substring(1, 1));
            }
     
            textBox2.Text = key.ToString();
        }
     
        void Button2Click(object sender, EventArgs e)
        {
            textBox2.SelectAll();
            textBox2.Copy();
        }

  2. #2
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 419
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 419
    Points : 5 818
    Points
    5 818
    Par défaut
    salut

    rien de bien compliqué a ta demande
    tout ce passe dans les événements
    je suppose que les textbox sont l'éqivalent de nos Tedit

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Procedure TMaForm.TextBox1TextOnChange(object sender)
    var
      str2 : string;
     key  : TStringList;
     i : Integer;
    begin
       key := TStringList.create;
    
    // for each digit in the serial number:
    // 1. convert it to int and add 5, then convert it back to string
    // 2. if the length of result string is > 1, take the second digit else take the first one
    // 3. append that digit to the end of the key
    
      for i := 0 To pred(length(textBox1.Text)) do 
      begin 
        str2 := IntTostr(StrToInt(Copy(trim(textBox1.Text),i, 1)) + 5));
        if (Length(str2) = 1)
           key.Add(str2)
        else 
          key.Add(Copy(str2,1, 1));
      end;
      textBox2.Text = key.Text;
    end;
    
    Procedure TMaForm.Button2Click(object sender)
    begin
      textBox2.SelectAll();
      textBox2.CopyToClipboard();
    end;
    le code n'est pas testé mais le principe est là
    Nous souhaitons la vérité et nous trouvons qu'incertitude. [...]
    Nous sommes incapables de ne pas souhaiter la vérité et le bonheur, et sommes incapables ni de certitude ni de bonheur.
    Blaise Pascal
    PS : n'oubliez pas le tag

  3. #3
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2016
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Janvier 2016
    Messages : 71
    Points : 19
    Points
    19
    Par défaut
    merci pour votre reponse,
    j'ai compiler mais j'ai eu ces erreurs :
    [dcc32 Error] Unit1.pas(47): E2003 Undeclared identifier: 'i'
    [dcc32 Error] Unit1.pas(49): E2029 'END' expected but ')' found
    [dcc32 Error] Unit1.pas(50): E2066 Missing operator or semicolon

  4. #4
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 445
    Points
    28 445
    Par défaut
    Citation Envoyé par mrsimo7 Voir le message
    merci pour votre reponse,
    j'ai compiler mais j'ai eu ces erreurs :
    [dcc32 Error] Unit1.pas(47): E2003 Undeclared identifier: 'i'
    [dcc32 Error] Unit1.pas(49): E2029 'END' expected but ')' found
    [dcc32 Error] Unit1.pas(50): E2066 Missing operator or semicolon
    il te manque "premiers pas avec Delphi" je pense...
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  5. #5
    Expert éminent
    Avatar de Lung
    Profil pro
    Analyste-programmeur
    Inscrit en
    Mai 2002
    Messages
    2 664
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste-programmeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2002
    Messages : 2 664
    Points : 6 967
    Points
    6 967
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    il te manque "premiers pas avec Delphi" je pense...
    +1

    Regarde par là :
    http://delphi.developpez.com/cours/
    L'urgent est fait, l'impossible est en cours, pour les miracles prévoir un délai. ___ Écrivez dans un français correct !!

    C++Builder 5 - Delphi 6#2 Entreprise - Delphi 2007 Entreprise - Delphi 2010 Architecte - Delphi XE Entreprise - Delphi XE7 Entreprise - Delphi 10 Entreprise - Delphi 10.3.2 Entreprise - Delphi 10.4.2 Entreprise - Delphi 11.1 Entreprise
    OpenGL 2.1 - Oracle 10g - Paradox - Interbase (XE) - PostgreSQL (15.4)

  6. #6
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2016
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Janvier 2016
    Messages : 71
    Points : 19
    Points
    19
    Par défaut
    merci a vous

  7. #7
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Bonjour ! Voici le code d'anapurna corrigé.
    Fichiers attachés Fichiers attachés
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  8. #8
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Janvier 2016
    Messages
    71
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Maroc

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Janvier 2016
    Messages : 71
    Points : 19
    Points
    19
    Par défaut
    Merci infiniment ça marche très bien

  9. #9
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Pas de quoi. Bonne continuation !
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 21/12/2012, 18h51
  2. [Système/Fichiers/API] probleme pour convertir Ptr du Delphi en BCB
    Par blondelle dans le forum C++Builder
    Réponses: 1
    Dernier message: 09/08/2012, 09h53
  3. Convertir Prolog en Delphi ou Pascal
    Par boubakeur dans le forum Prolog
    Réponses: 1
    Dernier message: 16/12/2006, 22h11
  4. Convertir Date sous Delphi vers Date sous MySQL
    Par forzaxelah dans le forum Bases de données
    Réponses: 12
    Dernier message: 21/07/2006, 12h06
  5. Convertir un composant Delphi 7 vers Delphi2005
    Par pointer dans le forum Composants VCL
    Réponses: 1
    Dernier message: 20/10/2005, 11h45

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo