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
| Imports System.Net
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
TextBox1.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim File_Input As Integer
Dim File_Output As Integer
Dim Ligne_String As String
Dim Ligne_String2 As String
Dim ips As IPAddress()
Dim position As Integer
If TextBox1.Text = "" Then 'si pas de fichier séléctionné
MsgBox("pas de fichier séléctionné", MsgBoxStyle.OkOnly, "ERREUR")
Else
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
File_Input = FreeFile() 'Get the available file number.
FileOpen(File_Input, TextBox1.Text, OpenMode.Input)
File_Output = FreeFile() 'Get the available file number.
FileOpen(File_Output, SaveFileDialog1.FileName, OpenMode.Output)
While Not EOF(File_Input)
Ligne_String = LineInput(File_Input) 'lie une ligne
position = Ligne_String.IndexOf("#[") 'retrouve l'index de #[
If position > -1 Then 's'il existe
Ligne_String = Mid(Ligne_String, 1, position - 1) 'supprime les commentaires de type #[...]
End If
If Not (Ligne_String.IndexOf("#") > -1) Then 'si pas de # dans la ligne
Ligne_String2 = Replace(Ligne_String, "127.0.0.1 ", "")
Try
TextBox2.Text = Ligne_String2 'affichage de l'adresse en cours
ips = Dns.GetHostAddresses(Ligne_String2) 'transforme l'adresse en IP
Print(File_Output, Ligne_String & " #" & ips(0).ToString & vbCrLf) 'recopie la ligne + adresse IP
Catch ex As Exception
Print(File_Output, Ligne_String & " ##########" & vbCrLf) 'recopie la ligne non resolu
End Try
Else
Print(File_Output, Ligne_String & vbCrLf) 'recopie la ligne
End If
End While
FileClose(File_Input) 'ferme le fichier de départ
FileClose(File_Output) 'ferme le fichier de sortie
MsgBox("fini !!!")
End If
End If
End Sub
End Class |
Partager