[vb.net] pb d'exécution d'un programme
Bonjour !
J'aimerais copier dans un fichier texte, à un endroit précis, des données que j'aurais récupérer de mon interface graphique.
Voici mon code :
Code:
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
| Function Rafraichissement_LSI()
Dim fileR As StreamReader
Dim fileW As StreamWriter
Dim ts As FileStream
Dim i, j As Integer
Dim tbl_string() As String
Dim cellule As String = listder_cellule.Text
Dim Date_debut As String = Date_deb.Text
Dim Date_final As String = Date_fin.Text
Dim logiciel As String = listder_lib_logi_micro.Text
Dim type_incident As String = listder_type_incident.Text
Dim domaine As String = listder_domaine_info.Text
MsgBox(Date_debut)
MsgBox(Date_final)
MsgBox(cellule)
MsgBox(logiciel)
MsgBox(type_incident)
MsgBox(domaine)
'modification de la date de traitement dans le fichier de paramètres Parambo.txt pour le prochain rafraichissement des requetes LSI
Dim file As New System.IO.StreamReader("\\beaqae\HDC_ESPACE_COMMUN\Statistiques\Applications\Developpements\Suivi_TR_NIV2\Parambo.txt")
i = 1
Do
ReDim Preserve tbl_string(i)
tbl_string(i) = file.ReadToEnd
If tbl_string(i) = "END" Then
Exit Do
End If
If tbl_string(i) Like "N,Cell = %" = True Then
tbl_string(i) = "N,Cell = " & cellule
End If
If tbl_string(i) Like "D,Date_deb = %" = True Then
tbl_string(i) = "D,Date_deb = " & Date_debut
End If
If tbl_string(i) Like "D,Date_fin = %" = True Then
tbl_string(i) = "D,Date_fin = " & Date_final
End If
If tbl_string(i) Like "N,Logiciel = %" = True Then
tbl_string(i) = "N,Logiciel = " & logiciel
End If
If tbl_string(i) Like "N,Type = %" = True Then
tbl_string(i) = "N,Type = " & type_incident
End If
If tbl_string(i) Like "N,Domaine = %" = True Then
tbl_string(i) = "N,Domaine = " & domaine
End If
i = i + 1
Loop
file.Close()
file = Nothing
Dim file1 As New System.IO.StreamWriter("\\beaqae\HDC_ESPACE_COMMUN\Statistiques\Applications\Developpements\Suivi_TR_NIV2\Parambo.txt")
For j = 1 To i
file1.WriteLine(tbl_string(j))
Next
file1.Close()
file1 = Nothing
End Function |
Je sais que mon programme n'avance pas car le do loop fait reboucler je ne sais combien de fois le code, et puis quand je décale le débuggueur afin de voir s'il m'écrit ce que je veux à la bonne place, et bien en faite il m'efface mon fichier texte et ne m'écrit rien.... :oops:
Faut-il que je prenne autre chose que StreamWriter ou StreamReader ? Ou quelque chose dans ce genre ?
Merci d'avance.:)
P.S : J'ai en faite repris un bout de programme en vba et essayer de la retranscrire en vb.net.
Si cela peut aider, je met le bout de programme en vba.
Code:
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
| Public Sub Ecriture_Parambo(ByVal DateTraitement As Date, ByVal Chemin As String)
Dim fs As New FileSystemObject
Dim ts As TextStream
Dim i As Integer
Dim tbl_string() As String
'modification de la date de traitement dans le fichier de paramètres Parambo.txt pour le prochain rafraichissement des requetes LSI
ts = fs.OpenTextFile(Chemin & "\Parambo.txt", ForReading)
i = 1
Do
ReDim Preserve tbl_string(i)
tbl_string(i) = ts.ReadLine
If tbl_string(i) = "END" Then
Exit Do
End If
If tbl_string(i) Like "D,DATE = *" = True Then
tbl_string(i) = "D,DATE = " & DateTraitement
End If
i = i + 1
Loop
ts.Close()
ts = fs.OpenTextFile(Chemin & "\Parambo.txt", ForWriting)
For j = 1 To i
ts.WriteLine(tbl_string(j))
Next
ts.Close()
ts = Nothing
fs = Nothing
End Sub |