[VBSCRIPT] String to ascii
Résolu
denstieven
Messages postés
663
Date d'inscription
Statut
Membre
Dernière intervention
-
denstieven Messages postés 663 Date d'inscription Statut Membre Dernière intervention -
denstieven Messages postés 663 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je creer un petit programme qui permet de convertir un mot en ascii. mais il y a un petit probleme. Il me dit que type de mid est incompatible.
Mon code:
J'espere que vous comprenez ce que je veux dire :D
Merci pour toutes corrections et explications :)
Denstieven
Je creer un petit programme qui permet de convertir un mot en ascii. mais il y a un petit probleme. Il me dit que type de mid est incompatible.
Mon code:
Set objShell = WScript.CreateObject("WScript.Shell") Const ForReading = 1, ForWriting = 2, ForAppending = 8 Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("nameinascii.txt", ForAppending, True) namsplit = 0 namsplit2 = 1 nam = Inputbox ("Enter your name:", "name to ascii") f.Write nam & " " namlenght = Len(nam) do namchars = Mid(nam, namsplit, namsplit2) namascii = Asc(namchars) f.Write namascii namsplit = namsplit + 1 namsplit2 = nampslit2 + 1 loop until namsplit2 = namlenght Msgbox "end "
J'espere que vous comprenez ce que je veux dire :D
Merci pour toutes corrections et explications :)
Denstieven
A voir également:
- [VBSCRIPT] String to ascii
- Code ascii - Guide
- Qwerty to azerty - Guide
- Video to video - Télécharger - Conversion & Codecs
- Your device ran into a problem and needs to restart - Forum Windows 10
- Majuscule to minuscule - Guide
2 réponses
Bonjour,
Il me semble bien que votre erreur est ici :
namsplit est le n° du caractère de début de Mid, "Start As Long". Or le caractère 0 n'existe pas. Un String débute par son 1er caractère non?
Remplacez donc par :
Il me semble bien que votre erreur est ici :
namsplit = 0
namsplit est le n° du caractère de début de Mid, "Start As Long". Or le caractère 0 n'existe pas. Un String débute par son 1er caractère non?
Remplacez donc par :
namsplit = 1
Merci ca marche!!!
Le code complet
Set objShell = WScript.CreateObject("WScript.Shell")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("nameinascii.txt", ForAppending, True)
namsplit = 1
'namsplit2 = 2
nam = Inputbox ("Enter your name:", "name to ascii")
f.Write nam & " "
namlenght = Len(nam)
do
namchars = Mid(nam, namsplit, 1)
namascii = Asc(namchars)
f.Write namascii
namsplit = namsplit + 1
'namsplit2 = nampslit2 + 1
loop until namsplit = namlenght
Msgbox "end "
Le f.write sert a ecrire dans le fichier nameinascii.txt
regarde: (Grand Merci Gord21 pour ce bout de code ^^)
Set objShell = WScript.CreateObject("WScript.Shell")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("nomdufichier.txt", ForAppending, True)
f.Write "Qu'est ce que tu veux"
Et grand merci a toi aussi pour m'avoir aidé et c'est resolu :D
Bonne journée encore ;)
Le code complet
Set objShell = WScript.CreateObject("WScript.Shell")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("nameinascii.txt", ForAppending, True)
namsplit = 1
'namsplit2 = 2
nam = Inputbox ("Enter your name:", "name to ascii")
f.Write nam & " "
namlenght = Len(nam)
do
namchars = Mid(nam, namsplit, 1)
namascii = Asc(namchars)
f.Write namascii
namsplit = namsplit + 1
'namsplit2 = nampslit2 + 1
loop until namsplit = namlenght
Msgbox "end "
Le f.write sert a ecrire dans le fichier nameinascii.txt
regarde: (Grand Merci Gord21 pour ce bout de code ^^)
Set objShell = WScript.CreateObject("WScript.Shell")
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("nomdufichier.txt", ForAppending, True)
f.Write "Qu'est ce que tu veux"
Et grand merci a toi aussi pour m'avoir aidé et c'est resolu :D
Bonne journée encore ;)
Mais a la fin toujours type incompatible ASC