Bonjour, en batch on peut tester un nombre s'il est plus grand ou plus petit que, peut on faire ca en VBS ?
Si oui comment ?
Bonjour, en batch on peut tester un nombre s'il est plus grand ou plus petit que, peut on faire ca en VBS ?
Si oui comment ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 dim i dim j i = 5 j = 6 If i < j Then 'ce que tu veux comme code msgbox i & " est plus petit que " & j Else 'ce que tu veux comme code msgbox i & " est plus grand que " & j End If
salut ced600, et merci beaucoup
en fait je souhaite convertir un script batch en vbs, voici le script en question: http://www.developpez.net/forums/sho...36#post3111036
J'ai fait ceci:
le script est senser créer un fichier lineLongue.txt pour y copier les ligne de plus de 3000 caractére, mais ca ne marche pas, pourai tu m'aider ?
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 ''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Ci-dessous on indique le chemin du fichier à traiter: vrFchTrait = "C:\Documents and Settings\Kookatix\Bureau\fichier.txt" ''''''''''''''''''''''''''''''''''''''''''''''''''''''' set WshShell = WScript.CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") DesktopPath = WSHShell.SpecialFolders("Desktop") Set FichierTXT = WScript.CreateObject("WScript.Shell") Dim fso, f Set f = fso.OpenTextFile(DesktopPath & "\lineLongue.txt", 8,true) Set objSourceFile = FSO.OpenTextFile(vrFchTrait, 1) Do Until objSourceFile.AtEndOfStream If Len(objSourceFile.ReadLine) > 3000 then f.writeline("objSourceFile.ReadLine") Else End If Loop objSourceFile.Close f.close
Enlève :
Ne fait pas de dim fso après un set fso = ....
Code : Sélectionner tout - Visualiser dans une fenêtre à part Set FichierTXT = WScript.CreateObject("WScript.Shell")
Et enlèce les Wscript. devant les createobject.
j'en suis la:
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
30
31
32
33
34
35
36 ''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Ci-dessous on indique le chemin du fichier à traiter: vrFchTrait = "C:\Documents and Settings\Kookatix\Bureau\fichier.txt" ''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim fso, f, f2 set WshShell = WScript.CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") DesktopPath = WSHShell.SpecialFolders("Desktop") Set FichierTXT = CreateObject("WScript.Shell") Set f = fso.OpenTextFile(DesktopPath & "\lineLongue.txt", 8,true) Set objSourceFile = FSO.OpenTextFile(vrFchTrait, 1) Do Until objSourceFile.AtEndOfStream If Len(objSourceFile.ReadLine) > 3000 then f.writeline(objSourceFile.ReadLine) Else vrLine = vrline & vbCrLf & objSourceFile.ReadLine End If Loop objSourceFile.Close f.close Const ForReading = 1, ForWriting = 2 Set FichierTXT2 = CreateObject("WScript.Shell") Set f2 = fso.OpenTextFile("Fichier2.txt", ForWriting,true) f2.writeline(vrLine) f2.close
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
30
31
32 ''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Ci-dessous on indique le chemin du fichier à traiter: vrFchTrait = "C:\Documents and Settings\Kookatix\Bureau\fichier.txt" ''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim fso, f, f2 Const ForReading = 1, ForWriting = 2, ForAppending = 8 'si je me souviens bien. 'l'intérêt des constantes est de les utiliser à chaque fois, sinon autant s'en passer et de mettre les chiffres. Mais dans le cas de FSO définir ces constantes est plus parlant que 1, 2 ou 8 set WshShell = CreateObject("WScript.Shell") Set FSO = CreateObject("Scripting.FileSystemObject") DesktopPath = WSHShell.SpecialFolders("Desktop") Set f = fso.OpenTextFile(DesktopPath & "\lineLongue.txt", ForAppending,true) Set objSourceFile = FSO.OpenTextFile(vrFchTrait, ForReading) Do Until objSourceFile.AtEndOfStream If Len(objSourceFile.ReadLine) > 3000 then f.writeline(objSourceFile.ReadLine) Else vrLine = vrline & vbCrLf & objSourceFile.ReadLine End If Loop objSourceFile.Close f.close Set f2 = fso.OpenTextFile("Fichier2.txt", ForWriting,true) f2.writeline(vrLine) f2.close
ca ne fonctionne toujour pas
les deux constante ne sont pas les même pour les deux fichioer créer par le code
Partager