Problème pour traducteur

sk8system Messages postés 5 Date d'inscription mardi 28 novembre 2006 Statut Membre Dernière intervention 11 décembre 2006 - 9 déc. 2006 à 21:12
sk8system Messages postés 5 Date d'inscription mardi 28 novembre 2006 Statut Membre Dernière intervention 11 décembre 2006 - 11 déc. 2006 à 20:30
Bonjour, j'ai beau avoir cherché un peu partout je ne vois pas comment faire pour résoudre mon problème. Je voulut créer un vbs capable de convertir un texte normal en ROT13. Pour ceux qui ne le save pas, le rot13 et une methode de "cryptage" qui effectue une rotation de 13 caractères à chaques lettres (ainsi, le "a" devient un "n" etc..).
J'ai donc fait le script (voir plus bas) mais comme vous le constaterez, il ne permet de "traduire" qu'une seule lettre à la fois (ce qui n'est pas très pratique ). J'aurais voulut savoir s'il existait une fonction permettant de pouvoir faire des traduction de mots complets, genre: "si il ya "a" faire "n" et/ ou si il ya "b" faire "o" etc...".
Merci d'avance.

Ci joint le script:

'variables


rien=""
un = "1"
deux = "2"




'***************************************
com = inputbox ("texte à rot13 (1) , rot13 à texte (2)","TPE 2006-2007")




'***************************************
If com = un then
texte = inputbox ("taper votre texte à traduire en rot13","TPE 2006-2007")
end if


'***************************************


if texte = "a" then
msgbox "n"
end if


if texte = "b" then
msgbox "o"
end if


if texte = "c" then
msgbox "p"
end if


if texte = "d" then
msgbox "q"
end if


if texte = "e" then
msgbox "r"
end if


if texte = "f" then
msgbox "s"
end if


if texte = "g" then
msgbox "t"
end if


if texte = "h" then
msgbox "u"
end if


if texte = "i" then
msgbox "v"
end if


if texte = "j" then
msgbox "w"
end if


if texte = "k" then
msgbox "x"
end if


if texte = "l" then
msgbox "y"
end if


if texte = "m" then
msgbox "z"
end if


if texte = "n" then
msgbox "a"
end if


if texte = "o" then
msgbox "b"
end if


if texte = "p" then
msgbox "c"
end if


if texte = "q" then
msgbox "d"
end if


if texte = "r" then
msgbox "e"
end if


if texte = "s" then
msgbox "f"
end if


if texte = "t" then
msgbox "g"
end if


if texte = "u" then
msgbox "h"
end if


if texte = "v" then
msgbox "i"
end if


if texte = "w" then
msgbox "j"
end if


if texte = "x" then
msgbox "k"
end if


if texte = "y" then
msgbox "l"
end if


if texte = "z" then
msgbox "m"
end if


'***************************************
If com = deux then
textee = inputbox ("taper votre ROT13 à convertir en texte","TPE 2006-2007")
end if


'***************************************
If textee = "n" then
msgbox "a"
end if


If textee = "o" then
msgbox "b"
end if


If textee = "p" then
msgbox "c"
end if


If textee = "q" then
msgbox "d"
end if


If textee = "r" then
msgbox "e"
end if


If textee = "s" then
msgbox "f"
end if


If textee = "t" then
msgbox "g"
end if


If textee = "u" then
msgbox "h"
end if


If textee = "v" then
msgbox "i"
end if


If textee = "w" then
msgbox "j"
end if


If textee = "x" then
msgbox "k"
end if


If textee = "y" then
msgbox "l"
end if


If textee = "z" then
msgbox "m"
end if


If textee = "a" then
msgbox "n"
end if


If textee = "b" then
msgbox "o"
end if


If textee = "c" then
msgbox "p"
end if


If textee = "d" then
msgbox "q"
end if


If textee = "e" then
msgbox "r"
end if


If textee = "f" then
msgbox "s"
end if


If textee = "g" then
msgbox "t"
end if


If textee = "h" then
msgbox "u"
end if


If textee = "i" then
msgbox "v"
end if


If textee = "j" then
msgbox "w"
end if


If textee = "k" then
msgbox "x"
end if


If textee = "l" then
msgbox "y"
end if


If textee = "m" then
msgbox "z"
end if


'***************************************

11 réponses

mortalino Messages postés 6786 Date d'inscription vendredi 16 décembre 2005 Statut Membre Dernière intervention 21 décembre 2011 18
9 déc. 2006 à 21:42
Salut,

je sais pas trop pour ton truc des mots, mais voici qui allegera ton code :

Ca c'est a toi :
if texte = "a" then
msgbox "n"
end if

if texte = "b" then
msgbox "o"
end if

if texte = "c" then
msgbox "p"
end if

if texte = "d" then
msgbox "q"
end if

if texte = "e" then
msgbox "r"
end if

if texte = "f" then
msgbox "s"
end if

if texte = "g" then
msgbox "t"
end if

if texte = "h" then
msgbox "u"
end if

if texte = "i" then
msgbox "v"
end if

if texte = "j" then
msgbox "w"
end if

if texte = "k" then
msgbox "x"
end if

if texte = "l" then
msgbox "y"
end if

if texte = "m" then
msgbox "z"
end if

if texte = "n" then
msgbox "a"
end if

if texte = "o" then
msgbox "b"
end if

if texte = "p" then
msgbox "c"
end if

if texte = "q" then
msgbox "d"
end if

if texte = "r" then
msgbox "e"
end if

if texte = "s" then
msgbox "f"
end if

if texte = "t" then
msgbox "g"
end if

if texte = "u" then
msgbox "h"
end if

if texte = "v" then
msgbox "i"
end if

if texte = "w" then
msgbox "j"
end if

if texte = "x" then
msgbox "k"
end if

if texte = "y" then
msgbox "l"
end if

if texte = "z" then
msgbox "m"
end if

<hr size="2" width="100%" />Ca c'est mon code :

    If Asc(TextBox1.Text) < 110 Then
        MsgBox Chr(Asc(TextBox1.Text) + 13)
    Else
        MsgBox Chr(Asc(TextBox1.Text) - 13)
    End If

Ton code et le mien font la même chose.

@++

<hr size="2" width="100%" />
  --Mortalino--
Le mystérieux chevalier, "Provençal, le Gaulois"
<!--
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
9 déc. 2006 à 21:43
Bonsoir,
Voici un exemple.
mid() permet de selectionner une partie de texte dans une chaine de caractère
asc() retourne le code ascii d'un caractère.
chr() retourne la lettre correspondant à un code ascii.

++




----------------------------------------------------
dim texteSource
dim texteSortie
texteSource = "Bienvenue sur Codes-Sources"


dim lngTexte
lngTexte = len(texteSource)


dim col()
redim col(lngTexte)


dim i
for i = 0 to lngTexte - 1
  col(i)=chr(asc(mid(texteSource,i+1,1))+13)
  texteSortie = texteSortie & col(i)
next


msgbox texteSortie
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
9 déc. 2006 à 22:07
 Bonjour à tous

C'est pas très joli tout ça....et les tableaux, c'est pour quoi faire ???
Pas cool les "If".

Il faudrait regarder les tutos sur array, dictionary, select case...etc

Un exemple tout simple:
Dim site(2)
site(0) = "ALES"
site(1) = "BOUR"
site(2) = "PNEU"
Dim Usine      :  Usine = Array(site(0), site(1), site(2))
MsgBox Usine(0) &vbCrLf& Usine(1) &vbCrLf& Usine(2)

Je suis en train d'écrire un script pour rechercher un mot dans des fichiers selon l'extension.
mais j'ai peur de t'embrouiller si je le poste.

jean-marc
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
9 déc. 2006 à 22:17
'soir JMO :)
Et moi, j'ai bien appris mes leçons (juste au dessus) ?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
9 déc. 2006 à 22:46
 Re,

Bonsoir Mortalino, ko ton bout code ...non !!!.
Bonsoir Willy, oui, je viens de tester ton code....C'est la bonne réponse, sans équivoque... 
(réponse que je n'avais pas et que je n'ai pas cherché....because les "If").

jean-marc
0
sk8system Messages postés 5 Date d'inscription mardi 28 novembre 2006 Statut Membre Dernière intervention 11 décembre 2006
10 déc. 2006 à 20:28
Merci d'avoir répondut aussi vite! Cependant je suis débutant donc je n'ai pas tout compris lol. Mais je vais chercher et je comprendrais mieu je pense! merci!
0
sk8system Messages postés 5 Date d'inscription mardi 28 novembre 2006 Statut Membre Dernière intervention 11 décembre 2006
11 déc. 2006 à 12:07
heu j'ai cherché un peu et si j'ai bien compris tu m'as donné un code vb.net willi. je suis seuleument intérréssé par un vb script moi lol
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
11 déc. 2006 à 12:20
 Bonjour à tous

Oh que non, le code de Willi s'applique pour un .vbs
Ce n'est pas du VB.Net.

'debut du copier
'-----------------------------------
'code de Willi,
dim texteSource
dim texteSortie
texteSource = "Bienvenue sur Codes-Sources"
dim lngTexte
lngTexte = len(texteSource)

dim col()
redim col(lngTexte)

dim i
for i = 0 to lngTexte - 1
  col(i)=chr(asc(mid(texteSource,i+1,1))+13)
  texteSortie = texteSortie & col(i)
next

msgbox texteSortie

'fin du copier
'-------------------------------------
Il faut ouvrir notepad, par exemple, puis:
Ctrl+V pour coller
et enregistrer sous "test_vbs.vbs (mettre tous les fichiers au lieu de .txt)
Puis, via explorer, double click sur le fichier pour l'exécuter.
Un msgbox apparaitra.....normalement !

jean-marc
0
sk8system Messages postés 5 Date d'inscription mardi 28 novembre 2006 Statut Membre Dernière intervention 11 décembre 2006
11 déc. 2006 à 20:07
oui merci jean-marc mais je sais enregistrer un vbs quand même! lol. c'est juste que losrque je met son script j'obtient une boite de message avec un seul bouton "ok" et avec écrit un texte imcompréhensible ("ovr{fr{,r"). Sa ne me semble pas très interréssant pour résoudre le problème de mes lettres de traducteur. je répète que je veux pouvoir "combiné" les lettres (voir énoncé). Bon sinan le problème vient de moi et je suis peut-être complètement stupide lol mais je rapelle que je ne suis qu'un simple débutant! merci.
0
cs_Willi Messages postés 2375 Date d'inscription jeudi 12 juillet 2001 Statut Modérateur Dernière intervention 15 décembre 2018 22
11 déc. 2006 à 20:21
sk8system, euh...tu le fais exprès la ?
tu obtiens un message incompréhensible. Tu demandes une convertion en 'ROT13' alors je l'applique tout simplement sur la chaine de caractères "Bienvenue sur Codes-Sources".
0
sk8system Messages postés 5 Date d'inscription mardi 28 novembre 2006 Statut Membre Dernière intervention 11 décembre 2006
11 déc. 2006 à 20:30
ha d'accord lol en même temps c'est pas du rot 13 sa! la rotation ne concerne ke les lettres. a devien  n, b devien o, [...] z devient m et c tou, toi ya plin de caracter etrange...
sinan sa a lair bien mé joré voulu avoir une input box avan ds lakel on tape notr texte a traduir (voir mon script) lol merci kan meme!!!
0
Rejoignez-nous