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

VBScript Discussion :

Récupérer des champs de visual studio pour les passer en paramètres dans un script vbs


Sujet :

VBScript

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2019
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Avril 2019
    Messages : 52
    Points : 37
    Points
    37
    Par défaut Récupérer des champs de visual studio pour les passer en paramètres dans un script vbs
    Bonjour, je programme actuellement un logiciel de conversion de fichier texte et j'ai un problème. Je cherche à faire passer en paramètre le chemin du fichier ainsi que le nom du nouveau fichier en ayant mis au préalable l'exécution du script sur le bouton "convertir" voici une capture de l'interface graphique pour que ce soit plus compréhensible:
    Nom : Capture2.JPG
Affichages : 345
Taille : 28,1 Ko

    Merci de me proposer une solution, je suis actuellement avec Visual Studio

  2. #2
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 805
    Points
    5 805
    Par défaut
    Si le script ne s'exécute que par appui sur le bouton Convertir, le chemin au fichier d'entrée et celui du fichier de sortie doivent être passés en Arguments audit script.

    Puis il y a une remarque : A quoi sert le second champ intitulé "Entrez le chemin du fichier à convertir" ?
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2019
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Avril 2019
    Messages : 52
    Points : 37
    Points
    37
    Par défaut
    En fait je demande le chemin d'un fichier a convertir et je le converti dans un nouveau fichier texte et tout ca je l'utilise dans mon code c'est pour cela qu'il faut que je le récupère.

  4. #4
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 805
    Points
    5 805
    Par défaut
    Citation Envoyé par lebonsavane Voir le message
    ....... c'est pour cela qu'il faut que je le récupère.
    Dans ce cas et pour être précis, le champ dont j'ai parlé devrait être intitulé "Entrez le chemin du fichier converti" en supprimant le "à" et le "r" à la fin non !!!!!!!
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2019
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Avril 2019
    Messages : 52
    Points : 37
    Points
    37
    Par défaut
    Ah oui oui, j'avais même pas vu autant pour moi ahaha

  6. #6
    Modérateur
    Avatar de l_autodidacte
    Homme Profil pro
    Retraité : Directeur de lycée/Professeur de sciences physiques
    Inscrit en
    Juillet 2009
    Messages
    2 415
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Retraité : Directeur de lycée/Professeur de sciences physiques
    Secteur : Enseignement

    Informations forums :
    Inscription : Juillet 2009
    Messages : 2 415
    Points : 5 805
    Points
    5 805
    Par défaut
    L'approche que je t'ai proposée est telle que celle écrite en VB6(car je n'ai pas d'autres versions plus récentes), facilement transformable en VB NET :
    Fichiers attachés Fichiers attachés
    Ne pas oublier le tag si satisfait.
    Voter pour toute réponse satisfaisante avec pour encourager les intervenants.
    Balises CODE indispensables. Regardez ICI
    Toujours utiliser la clause Option Explicit(VBx, VBS ou VBA) et Ne jamais typer variables et/ou fonctions en VBS.
    Vous pouvez consulter mes contributions
    Ne pas oublier de consulter les différentes FAQs et les Cours/Tutoriels VB6/VBScript
    Ne pas oublier L'Aide VBScript et MSDN VB6 Fr

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2019
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Avril 2019
    Messages : 52
    Points : 37
    Points
    37
    Par défaut
    Je comprends bien mais la ça ne peux pas résoudre mon problème voici mon code est ce que tu pourrais me dire pourquoi l'appel avec arguments ne fonctionne pas:
    Code sur le .vbs :
    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
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
     
     
    Dim TblLgns, TblMots(), Tbl2d(), Tbl_arg1
    Dim fso, fichier, T, U, V, D2max
    Dim ContenuFichier, TblCol
    Dim ChemNomFichier
    Dim chaine
    Dim oFich2
    Dim i 
    Dim w
    Dim n1
    Dim n
    Dim strSearchFor
    Dim z 
    Dim m
    Dim o
    Dim x
    Dim a
    Dim p
    Dim WshShell
    Dim demander
    Dim nomdefichier
    Dim NewFichier
    Dim OrigineFichier
    Dim Txt_tbl
    Dim Newfichier2
    Const ForReading = 1, ForWriting = 2
    Dim nouveau_arg1
    Dim arg1_ext
     
     
    strSearchFor = "ODP3"
        'ChemNomFichier = InputBox("Quel est le chemin du fichier à exporter au format npm ? (Ne rentrez pas l'extension du fichier)", "Chemin du fichier à importer")
        'NewFichier = ChemNomFichier & ".txt"
        'OrigineFichier = ChemNomFichier & ".TRA"
      msgBox arg1 
        Set WshShell = WScript.CreateObject("WScript.Shell")
        Set fso = CreateObject("Scripting.FileSystemObject")
        'fso.MoveFile OrigineFichier, ChemNomFichier & ".txt"
        'Rename (OrigineFichier, ChemNomFichier & ".txt")
        Tbl_arg1=Split(arg1,"\")
        p = Ubound(Tbl_arg1) - 1
        nouveau_arg1 = Tbl_arg1(1)
        MsgBox nouveau_arg1
        arg1_ext = Replace(arg1, ".TRA", ".txt")
        fso.MoveFile nouveau_arg1, arg1_ext
        ChemNomFichier = arg1_ext
        Set fichier = fso.opentextfile(ChemNomFichier, 1)
        ContenuFichier = fichier.ReadAll
        fichier.Close
        Set fichier = Nothing
        Set fso = Nothing
     
        D2max = 1 'pour trouver la ligne qui a le plus de mots (colonnes)
          TblLgns = Split(ContenuFichier,vbNewline) 'on recupère le tableau de lignes
    For i = 1 To Ubound(TblLgns)
        n1 = TblLgns(i)
        If InStr(1, n1, strSearchFor,vbTextCompare) <> 0 then
           Exit For
        End If
    Next 
     
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set fichier = fso.opentextfile(ChemNomFichier, 1)
        ContenuFichier = fichier.ReadAll
        fichier.Close
        Set fichier = Nothing
        Set fso = Nothing
     
        D2max = 1 'pour trouver la ligne qui a le plus de mots (colonnes)
          TblLgns = Split(ContenuFichier,vbNewline) 'on recupère le tableau de lignes
        For T = 0 To UBound(TblLgns)
          TblCol = Split(TblLgns(T), " ", -1, 1)
          If D2max < UBound(TblCol) Then D2max = UBound(TblCol)
        Next
        'maintenant que l'on a les 2 dimensions du tableau ... 
        Redim Tbl2d(UBound(TblLgns), D2max)' on le dimensionne
        V=0 'pour incrémenter/dimensionner le tableau des mots
     
        For T = 0 To UBound(TblLgns)
          TblCol = Split(TblLgns(T), " ", -1, vbTextCompare)' on optient chaque mots de la ligne
          For U = 0 To UBound(TblCol)' on boucle pour ....
            Tbl2d(T,U)= TblCol(U) 'remplissage du tableau 2D
            Redim Preserve TblMots(V)'on dimensionne au fur et a mesure le tableau de mots
            TblMots(V) = TblCol(U) 'remplissage du tableau de mots
            V=V+1
          Next
        Next
          'Coller le resultat avec la bonne mise en forme 
      'demander = InputBox ("Quel est le chemin du fichier à créer ?", "Création fichier texte")
      'nomdefichier = InputBox ("Quel est le nom du fichier à créer ? (Ne pas mettre d'extension)", "Création fichier texte")
      Set WshShell = WScript.CreateObject("WScript.Shell")
      Set fso = CreateObject("Scripting.FileSystemObject")
      'Newfichier2 = nomdefichier & ".txt"
      nomdefichier = arg2 & ".txt"
      Set oFich2=fso.OpenTextFile(nomdefichier,2,True)
      oFich2.write "Import"
      OFich2.Write vbNewline
          'Calcul pour que ce soit aligné
    For w = i to Ubound(Tbl2d)
     'w = w + 28
        If Tbl2D (w,11) <> "" Then 
        Txt_tbl = Tbl2D(w, 11)
          Tbl2D(w,11) =(Replace(Txt_tbl,"0", " " ))
           ' If Tbl2D(w,52)<> "" Then o = 11
            'If Tbl2D(w,51) <> "" Then o = 10
           ' If Tbl2D(w,50) <> "" Then o = 9
           ' If Tbl2D(w,49) <> "" Then o = 8
           ' If Tbl2D(w,48) <> "" Then o = 7
           ' If Tbl2D(w,47) <> "" Then o = 6
           ' If Tbl2D(w,46) <> "" Then o = 5        
            'MsgBox "ca c'es o" & o
            'MSgBox w
            If Tbl2d(w,35) <> "" Then
              m = Len(Tbl2d(w,29)& Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32) & Tbl2d(w,33) & Tbl2d(w,34) & Tbl2D(w,35))
              n = 46-m
              If Tbl2D(w,29 + n + 1) <> "" Then o = 10
              If Tbl2D(w,29 + n + 11) <> "" Then o = 11
                If Tbl2D(w,29 + n + 12) <> "" Then o = 12
                If Tbl2D(w,29 + n + 13) <> "" Then o = 13
                If Tbl2D(w,29 + n + 14) <> "" Then o = 14
                If Tbl2D(w,29 + n + 15) <> "" Then o = 15
              x = n + o
              oFich2.Write Tbl2d(w,0) & vbTab & Tbl2d(w,11) & "       " & Tbl2d(w,22) & " " &Tbl2d(w,23) & " " & Tbl2d(w,24) & Tbl2d(w,29) & Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32) & Tbl2d(w,33) & Tbl2d(w,34) & Tbl2D(w,35) & Space(n) & Tbl2d(w,29 + n ) & Space(o) & Tbl2d(w,29 + x) & Space(7) & Left(Tbl2D(w,36 + x), 1) & Space(26) & Mid(Tbl2D(w,36 + x), 2, 3) & Space(23) & "1" & Space(9) & Tbl2d(w,11) & Space(19)
              oFich2.Write vbNewline
            ElseIf Tbl2d(w,34) <> "" Then
              m = Len(Tbl2d(w,29)& Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32) & Tbl2d(w,33) & Tbl2d(w,34))
              n = 46-m
              If Tbl2D(w,29 + n + 11) <> "" Then o = 11
                If Tbl2D(w,29 + n + 12) <> "" Then o = 12
                If Tbl2D(w,29 + n + 13) <> "" Then o = 13
                If Tbl2D(w,29 + n + 14) <> "" Then o = 14
                If Tbl2D(w,29 + n + 15) <> "" Then o = 15
              x = n + o
              oFich2.Write Tbl2d(w,0) & vbTab & Tbl2d(w,11) & "       " & Tbl2d(w,22) & " " &Tbl2d(w,23) & " " & Tbl2d(w,24) & Tbl2d(w,29) & Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32) & Tbl2d(w,33) & Tbl2d(w,34) & Space(n) & Tbl2d(w,29 + n ) & Space(o) & Tbl2d(w,29 + x) & Space(7) &  Left(Tbl2D(w,36 + x), 1)  & Space(26) & Mid(Tbl2D(w,36 + x), 2, 3) & Space(23) & "1" & Space(9) & Tbl2d(w,11) & Space(19)
              oFich2.Write vbNewline
            ElseIf Tbl2d(w,33) <> "" Then
              m = Len(Tbl2d(w,29)& Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32) & Tbl2d(w,33))
              n = 46-m
               If Tbl2D(w,29 + n + 11) <> "" Then o = 11
                If Tbl2D(w,29 + n + 12) <> "" Then o = 12
                If Tbl2D(w,29 + n + 13) <> "" Then o = 13
                If Tbl2D(w,29 + n + 14) <> "" Then o = 14
                If Tbl2D(w,29 + n + 15) <> "" Then o = 15
              x = n + o
              oFich2.Write Tbl2d(w,0) & vbTab & Tbl2d(w,11) & "       " & Tbl2d(w,22) & " " &Tbl2d(w,23) & " " & Tbl2d(w,24) & Tbl2d(w,29) & Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32) & Tbl2d(w,33) & Space(n) & Tbl2d(w,29 + n ) & Space(o) & Tbl2d(w,29 + x) & Space(7) & Left(Tbl2D(w,36 + x), 1)  & Space(26) & Mid(Tbl2D(w,36 + x), 2, 3) & Space(23) & "1" & Space(9) & Tbl2d(w,11) & Space(19)
              oFich2.Write vbNewline
            ElseIf Tbl2d(w,32) <> "" Then
              m = Len(Tbl2d(w,29)& Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32))
              n = 46-m
               If Tbl2D(w,29 + n + 11) <> "" Then o = 11
                If Tbl2D(w,29 + n + 12) <> "" Then o = 12
                If Tbl2D(w,29 + n + 13) <> "" Then o = 13
                If Tbl2D(w,29 + n + 14) <> "" Then o = 14
                If Tbl2D(w,29 + n + 15) <> "" Then o = 15
              x = n + o
              oFich2.Write Tbl2d(w,0) & vbTab & Tbl2d(w,11) & "       " & Tbl2d(w,22) & " " &Tbl2d(w,23) & " " & Tbl2d(w,24) & Tbl2d(w,29) & Tbl2d(w,30) & Tbl2d(w,31) & Tbl2d(w,32) & Space(n) & Tbl2d(w,29 + n ) & Space(o) & Tbl2d(w,29 + x) & Space(7) & Left(Tbl2D(w,36 + x), 1) & Space(26) & Mid(Tbl2D(w,36 + x), 2, 3) & Space(23) & "1" & Space(9) & Tbl2d(w,11) & Space(19)
              oFich2.Write vbNewline
            ElseIf Tbl2d(w,31) <> "" Then
              m = Len(Tbl2d(w,29)& Tbl2d(w,30) & Tbl2d(w,31))
              n = 46-m
               If Tbl2D(w,29 + n + 11) <> "" Then o = 11
                If Tbl2D(w,29 + n + 12) <> "" Then o = 12
                If Tbl2D(w,29 + n + 13) <> "" Then o = 13
                If Tbl2D(w,29 + n + 14) <> "" Then o = 14
                If Tbl2D(w,29 + n + 15) <> "" Then o = 15
              x = n + o
              oFich2.Write Tbl2d(w,0) & vbTab & Tbl2d(w,11) & "       " & Tbl2d(w,22) & " " &Tbl2d(w,23) & " " & Tbl2d(w,24) & Tbl2d(w,29) & Tbl2d(w,30) & Tbl2d(w,31) & Space(n) & Tbl2d(w,29 + n ) & Space(o) & Tbl2d(w,29 + x) & Space(7) & Left(Tbl2D(w,36 + x), 1)  & Space(26) & Mid(Tbl2D(w,36 + x), 2, 3) & Space(23) & "1" & Space(9) & Tbl2d(w,11) & Space(19)
              oFich2.Write vbNewline
            ElseIf Tbl2d(w,30) <> "" Then
              m = Len(Tbl2d(w,29)& Tbl2d(w,30))
              n = 46-m
               If Tbl2D(w,29 + n + 11) <> "" Then o = 11
                If Tbl2D(w,29 + n + 12) <> "" Then o = 12
                If Tbl2D(w,29 + n + 13) <> "" Then o = 13
                If Tbl2D(w,29 + n + 14) <> "" Then o = 14
                If Tbl2D(w,29 + n + 15) <> "" Then o = 15
              x = n + o
              oFich2.Write Tbl2d(w,0) & vbTab & Tbl2d(w,11) & "       " & Tbl2d(w,22) & " " &Tbl2d(w,23) & " " & Tbl2d(w,24) & Tbl2d(w,29) & Tbl2d(w,30) & Space(n) & Tbl2d(w,29 + n ) & Space(o) & Tbl2d(w,29 + x) & Space(7) & Left(Tbl2D(w,36 + x), 1) & Space(26) & Mid(Tbl2D(w,36 + x), 2, 3) & Space(23) & "1" & Space(9) & Tbl2d(w,11) & Space(19)
              oFich2.Write vbNewline
            Else 
              m = Len(Tbl2D(w,29))
              n = 46 - m
               If Tbl2D(w,29 + n + 11) <> "" Then o = 11
                If Tbl2D(w,29 + n + 12) <> "" Then o = 12
                If Tbl2D(w,29 + n + 13) <> "" Then o = 13
                If Tbl2D(w,29 + n + 14) <> "" Then o = 14
                If Tbl2D(w,29 + n + 15) <> "" Then o = 15
              x = n + o
              oFich2.Write Tbl2d(w,0) & vbTab & Tbl2d(w,11) & "       " & Tbl2d(w,22) & " " &Tbl2d(w,23) & " " & Tbl2d(w,24) & Tbl2d(w,29) & Space(n) & Tbl2d(w,29 + n ) & Space(o) & Tbl2d(w,29 + x) & Space(7) & Left(Tbl2D(w,36 + x), 1) & Space(26) & Mid(Tbl2D(w,36 + x), 2, 3) & Space(23) & "1" & Space(9) & Tbl2d(w,11) & Space(19)
              oFich2.Write vbNewline
            End If
        Else  
            'If Tbl2D(w,53)<> "" Then o = 5
           '' If Tbl2D(w,54) <> "" Then o = 6
            'If Tbl2D(w,55) <> "" Then o = 7
            'If Tbl2D(w,56) <> "" Then o = 8
           ' If Tbl2D(w,57) <> "" Then o = 9
            ''If Tbl2D(w,58) <> "" Then o = 10
            'If Tbl2D(w,59) <> "" Then o = 11
            If Tbl2D(w,42)<> "" Then 
                m = Len(Tbl2d(w,36)& Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39) & Tbl2d(w,40) & Tbl2d(w,41) & Tbl2D(w,42))
                n = 38-m
                If Tbl2D(w,36 + n + 10) <> "" Then o = 10
                If Tbl2D(w,36 + n + 11) <> "" Then o = 11
                If Tbl2D(w,36 + n + 12) <> "" Then o = 12
                If Tbl2D(w,36 + n + 13) <> "" Then o = 13
                If Tbl2D(w,36 + n + 14) <> "" Then o = 14
                If Tbl2D(w,36 + n + 15) <> "" Then o = 15
                x = n + o
                oFich2.Write Tbl2d(w,0) & vbTab & "              " & Tbl2d(w,29) & " " &Tbl2d(w,30) & " " & Tbl2d(w,31) & Tbl2d(w,36) & Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39) & Tbl2d(w,40) & Tbl2d(w,41) & Tbl2D(w,42) & Space(n) & Tbl2d(w,36 + n ) & Space(o) & Tbl2d(w,36 + x) & Space(7) & Left(Tbl2D(w,43+x),1) & Space(26) & Mid(Tbl2D(w,43 + x),2 , 3)
                    oFich2.Write vbNewline
             ElseIf Tbl2D(w,41)<> "" Then 
                m = Len(Tbl2d(w,36)& Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39) & Tbl2d(w,40) & Tbl2d(w,41))
                n = 38-m
                If Tbl2D(w,36 + n + 11) <> "" Then o = 11
                If Tbl2D(w,36 + n + 12) <> "" Then o = 12
                If Tbl2D(w,36 + n + 13) <> "" Then o = 13
                If Tbl2D(w,36 + n + 14) <> "" Then o = 14
                If Tbl2D(w,36 + n + 15) <> "" Then o = 15
                x = n + o
                oFich2.Write Tbl2d(w,0) & vbTab & "              " & Tbl2d(w,29) & " " &Tbl2d(w,30) & " " & Tbl2d(w,31) & Tbl2d(w,36) & Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39) & Tbl2d(w,40) & Tbl2d(w,41) & Space(n) & Tbl2d(w,36 + n ) & Space(o) & Tbl2d(w,36 + x) & Space(7) & Left(Tbl2D(w,43+x),1) & Space(26) & Mid(Tbl2D(w,43 + x),2 , 3)
                    oFich2.Write vbNewline
            ElseIf Tbl2D(w,40) <> "" Then 
                m = Len(Tbl2d(w,36)& Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39) & Tbl2d(w,40))
                n = 38-m
                If Tbl2D(w,36 + n + 11) <> "" Then o = 11
                If Tbl2D(w,36 + n + 12) <> "" Then o = 12
                If Tbl2D(w,36 + n + 13) <> "" Then o = 13
                If Tbl2D(w,36 + n + 14) <> "" Then o = 14
                If Tbl2D(w,36 + n + 15) <> "" Then o = 15
                x = n + o
                oFich2.Write Tbl2d(w,0) & vbTab & "              " & Tbl2d(w,29) & " " &Tbl2d(w,30) & " " & Tbl2d(w,31) & Tbl2d(w,36) & Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39) & Tbl2d(w,40) & Space(n) & Tbl2d(w,36 + n ) & Space(o) & Tbl2d(w,36 + x) & Space(7) & Left(Tbl2D(w,43+x),1) & Space(26) & Mid(Tbl2D(w,43 + x),2 , 3)
                oFich2.Write vbNewline
            ElseIf Tbl2D(w,39) <> "" Then
                m = Len(Tbl2d(w,36)& Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39))
                n = 38-m
                If Tbl2D(w,36 + n + 11) <> "" Then o = 11
                If Tbl2D(w,36 + n + 12) <> "" Then o = 12
                If Tbl2D(w,36 + n + 13) <> "" Then o = 13
                If Tbl2D(w,36 + n + 14) <> "" Then o = 14
                If Tbl2D(w,36 + n + 15) <> "" Then o = 15
                x = n + o
                oFich2.Write Tbl2d(w,0) & vbTab & "              " & Tbl2d(w,29) & " " &Tbl2d(w,30) & " " & Tbl2d(w,31) & Tbl2d(w,36) & Tbl2d(w,37) & Tbl2d(w,38) & Tbl2d(w,39) & Space(n) & Tbl2d(w,36 + n ) & Space(o) & Tbl2d(w,36 + x) & Space(7) & Left(Tbl2D(w,43+x),1) & Space(26) & Mid(Tbl2D(w,43 + x),2 , 3)
                oFich2.Write vbNewline
            ElseIf Tbl2D(w,38) <> "" Then
                m = Len(Tbl2d(w,36)& Tbl2d(w,37) & Tbl2d(w,38))
                n = 38-m
                If Tbl2D(w,36 + n + 11) <> "" Then o = 11
                If Tbl2D(w,36 + n + 12) <> "" Then o = 12
                If Tbl2D(w,36 + n + 13) <> "" Then o = 13
                If Tbl2D(w,36 + n + 14) <> "" Then o = 14
                If Tbl2D(w,36 + n + 15) <> "" Then o = 15
                x = n + o
                oFich2.Write Tbl2d(w,0) & vbTab & "              " & Tbl2d(w,29) & " " &Tbl2d(w,30) & " " & Tbl2d(w,31) & Tbl2d(w,36) & Tbl2d(w,37) & Tbl2d(w,38) & Space(n) & Tbl2d(w,36 + n ) & Space(o) & Tbl2d(w,36 + x) & Space(7) & Left(Tbl2D(w,43+x),1) & Space(26) & Mid(Tbl2D(w,43 + x),2 , 3)
                oFich2.Write vbNewline
                  'MsgBox n 
              ' MsgBox m
                'MsgBox Tbl2D(w, 36 + n)
                'MSgBox Tbl2D(w,z)
            ElseIf Tbl2D(w,37) <> "" Then
                m = Len(Tbl2d(w,36)& Tbl2d(w,37))
                n = 38-m
                If Tbl2D(w,36 + n + 11) <> "" Then o = 11
                If Tbl2D(w,36 + n + 12) <> "" Then o = 12
                If Tbl2D(w,36 + n + 13) <> "" Then o = 13
                If Tbl2D(w,36 + n + 14) <> "" Then o = 14
                If Tbl2D(w,36 + n + 15) <> "" Then o = 15
                x = n + o
                oFich2.Write Tbl2d(w,0) & vbTab & "              " & Tbl2d(w,29) & " " &Tbl2d(w,30) & " " & Tbl2d(w,31) & Tbl2d(w,36) & Tbl2d(w,37) & Space(n) & Tbl2d(w,36 + n ) & Space(o) & Tbl2d(w,36 + x) & Space(7) & Left(Tbl2D(w,43+x),1) & Space(26) & Mid(Tbl2D(w,43 + x),2 , 3)
                oFich2.Write vbNewline
            ElseIf Tbl2D (w,36) <> "" Then 
                m = Len(Tbl2d(w,36))
                n = 38-m
                If Tbl2D(w,36 + n + 11) <> "" Then o = 11
                If Tbl2D(w,36 + n + 12) <> "" Then o = 12
                If Tbl2D(w,36 + n + 13) <> "" Then o = 13
                If Tbl2D(w,36 + n + 14) <> "" Then o = 14
                If Tbl2D(w,36 + n + 15) <> "" Then o = 15
                x = n + o
                oFich2.Write Tbl2d(w,0) & vbTab & "              " & Tbl2d(w,29) & " " &Tbl2d(w,30) & " " & Tbl2d(w,31) & Tbl2d(w,36) & Space(n) & Tbl2d(w,36 + n ) & Space(o) & Tbl2d(w,36 + x) & Space(7) & Left(Tbl2D(w,43+x),1) & Space(26) & Mid(Tbl2D(w,43 + x),2 , 3)
                oFich2.Write vbNewline
            End If
     
          End If
     
    Next 
          ' Nettoyage des variables a la fin 
      'fso.MoveFile Newfichier2, nomdefichier & ".pnm" 
      Set oFich2 = Nothing
      Set fso = Nothing

    Et voici comment je l'appelle avec le bouton convertir depuis Visual Studio :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
      Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
            Dim path1
            Dim arg1 As String
            Dim arg2 As String
            path1 = "C:\Script_vbs\1.vbs"
            arg1 = TextBox1.Text
            arg2 = TextBox6.Text
            Call Shell("wscript" & " " & path1 & " " & ", " & arg1 & ", " & arg2)
     
     
        End Sub
    Merci d'essayer de me répondre ..

  8. #8
    Modérateur
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 077
    Points : 17 172
    Points
    17 172
    Par défaut
    Salut

    Voici un code VBScript qui récupère le/les arguments de la ligne de commande.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Dim RecupArguments
    If wscript.Arguments.length >= 2 then
    	RecupArguments = "La ligne d'execution du programme est " _
    	& vbNewLine & wscript.FullName
     
    	For T = 0 to wscript.Arguments.length-1
    		RecupArguments = RecupArguments & " " & wscript.arguments(T)
    	Next
    	MsgBox RecupArguments, vbinformation, T & " argument(s)"
    	Else
    	MsgBox "Le programme ""Argument.vbs"" a été lancé sans aucun argument.", vbinformation
    End If
    Depuis ton programme vb.net, lances le de cette façon
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Call Shell("wscript" & " " & path1 & " " & ", " & arg1 & ", " & arg2)
    path1 doit être le chemin et nom du programme qui récupère les arguments (ici le programme ci-dessus), normalement tu devrais avoir le message VBSCript.exe MonArgument1, MonArgument2.
    Si cela ne fonctionne pas, essais de lancer le programme depuis une session DOS ou passe par le shell exécuter de widows.
    Soyez sympa, pensez -y
    Balises[CODE]...[/CODE]
    Balises[CODE=NomDuLangage]...[/CODE] quand vous mettez du code d'un autre langage que celui du forum ou vous postez.
    Balises[C]...[/C] code intégré dans une phrase.
    Balises[C=NomDuLangage]...[/C] code intégré dans une phrase quand vous mettez du code d'un autre langage que celui du forum ou vous postez.
    Le bouton en fin de discussion, quand vous avez obtenu l'aide attendue.
    ......... et pourquoi pas, pour remercier, un pour celui/ceux qui vous ont dépannés.
    👉 → → Ma page perso sur DVP ← ← 👈

  9. #9
    Inactif  

    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2012
    Messages
    4 904
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : Canada

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Janvier 2012
    Messages : 4 904
    Points : 10 168
    Points
    10 168
    Billets dans le blog
    36
    Par défaut
    Franchement. Utiliser VBScript pour convertir in fichier texte après avoir récupéré des données d'un programme VB, c'est carrément stupide au cube. Visual Studio a tout ce qu'il faut en interne pour convertir ton fichier.

    Mais, bien sûr, comme d'habitude tu as la science infuse, tu réponds en paraboles et il ne faut pas questionner TA méthode; même si c'est tout ce qu'il y a de plus ridicule.

    Mais bon, si les autres veulent jouer à ton jeu, c'est leur problème. Moi, j'ai assez donné.
    À ma connaissance, le seul personnage qui a été diagnostiqué comme étant allergique au mot effort. c'est Gaston Lagaffe.

    Ô Saint Excel, Grand Dieu de l'Inutile.

    Excel n'a jamais été, n'est pas et ne sera jamais un SGBD, c'est pour cela que Excel s'appelle Excel et ne s'appelle pas Access junior.

  10. #10
    Modérateur
    Avatar de ProgElecT
    Homme Profil pro
    Retraité
    Inscrit en
    Décembre 2004
    Messages
    6 077
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 68
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Décembre 2004
    Messages : 6 077
    Points : 17 172
    Points
    17 172
    Par défaut
    Salut

    @clementmarcotte, je suis de ton avis, je pense que lebonsavane maitrise mieux VBScript que VB.net, mais s'il arrive à faire fonctionner son/ses programme(s) avec les bouts de code qu'il nous fait voir, dans un dernier temps je lui proposerai un code HTA, du HTML pour la partie saisie avec intégré dedans le VBScript qu'il aura déjà travaillé, se qui serait déjà plus cohérent.
    Soyez sympa, pensez -y
    Balises[CODE]...[/CODE]
    Balises[CODE=NomDuLangage]...[/CODE] quand vous mettez du code d'un autre langage que celui du forum ou vous postez.
    Balises[C]...[/C] code intégré dans une phrase.
    Balises[C=NomDuLangage]...[/C] code intégré dans une phrase quand vous mettez du code d'un autre langage que celui du forum ou vous postez.
    Le bouton en fin de discussion, quand vous avez obtenu l'aide attendue.
    ......... et pourquoi pas, pour remercier, un pour celui/ceux qui vous ont dépannés.
    👉 → → Ma page perso sur DVP ← ← 👈

  11. #11
    Nouveau membre du Club
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2019
    Messages
    52
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Morbihan (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Avril 2019
    Messages : 52
    Points : 37
    Points
    37
    Par défaut
    Je vous remercie tous pour vos réponse j'ai réussi à trouver la solution qui etait en fait tout simplement d'utiliser ce que montrait ProgElec avec le Wscripts.Arguments
    merci à tous

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

Discussions similaires

  1. [Google Sheets] Récupèrer des données coté Tableur Serveur pour les utiliser coté Client dans la BarSide
    Par comme de bien entendu dans le forum APIs Google
    Réponses: 1
    Dernier message: 21/01/2019, 11h38
  2. Réponses: 2
    Dernier message: 16/09/2009, 16h51
  3. Réponses: 0
    Dernier message: 10/08/2008, 19h05
  4. Réponses: 2
    Dernier message: 24/10/2007, 12h18
  5. Réponses: 1
    Dernier message: 31/01/2007, 11h59

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