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
| Imports System.IO
Imports System.Text
'DUT ANALYSER
Public Class Form1
Dim chemin, path, bloc, x, y, z As String
Dim testpos, i As Integer
Dim pathwriter As StreamWriter
Dim lst As New List(Of String)
Private Sub odtbut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles odtbut.Click
If path = "" Then
MsgBox("Please, select first a destination file", MsgBoxStyle.Exclamation, "No destination file")
Else
'select only txt files
OpenFileDialog1.Filter = "Text (*.txt)|*.txt"
OpenFileDialog1.Multiselect = True
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
'open a window to choose the path of the TXT file
chemin = OpenFileDialog1.FileName
lst.Add(chemin)
For Each chemin In lst
'the file is readed by this application
Dim file() As String = IO.File.ReadAllLines(chemin)
Dim nblignes = file.Length - 1
'lbl1.Text = file(4).ToString 'used to see if the programm worked
'lbl2.Text = file(94).ToString
'comparaison is done with the number of lines : the test stop automatically when it fails, so you always have
'less datas than a passed test : it means less lines
' if the test is failed, this programm will search all lines where test failed
'test
y = Mid(file(3), 45, 6) 'we take the serial number
z = Mid(file(4), 35, 6)
lbl1.Text = y
lbl2.Text = z
'we write in the TXT document we opened earlier (the final one)
pathwriter = New StreamWriter(path, True, Encoding.Unicode)
If nblignes < 94 Then
pathwriter.WriteLine(y & ";" & z & ";" & nblignes & "failed")
lbl3.Text = nblignes & " " & "failed"
Else
pathwriter.WriteLine(y & ";" & z & ";" & nblignes & "success")
lbl3.Text = nblignes & " " & "success"
End If
pathwriter.Close()
'print the number of files tested
i = i + 1
lbl5.Text = i
Next
Else
MsgBox("No file selected, please choose one file", MsgBoxStyle.Exclamation, "No file selected")
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'we pick up the path of the tested folder
'select only txt files
OpenFileDialog2.Filter = "Text (*.txt)|*.txt"
If OpenFileDialog2.ShowDialog() = Windows.Forms.DialogResult.OK Then
path = OpenFileDialog2.FileName
' i is the counter of txt documents you analyse
i = 0
Button1.Enabled = False 'to avoid missclicks
Else
MsgBox("No file selected, please choose one file", MsgBoxStyle.Exclamation, "No file selected")
End If
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
path = ""
End Sub
End Class |
Partager