Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

PING SUR UN INTERVALLE D'ADRESSE IP


Information sur la source

Description

Cliquez pour voir la capture en taille normale
Ce petit utilitaire conçue pour les besoins de mon travail fait partie d'une plus grande application. Il teste les connections reseaux pour un interval de 2 adresses IP, et presantant les resultats dans une liste avec la reponse du ping (Timeout, Succes en X ms) et le nom de l'hote en cas de succes.

   Vous reconnettrez certain code copier sur ce site, et que je remercie leur auteurs.
 

Source

  • Public r As Integer
  • Public g As String
  • Public R1 As Integer
  • Public suc As Integer
  • Private Sub Command1_Click()
  • Dim T, d As String
  • Dim x As Integer
  • Dim A1, A2, A3 As Long
  • test = " Debut du Ping sur l'interval [" & d & " - " & T & "]."
  • x = 1
  • suc = 0
  • Call Ini_Pbar ' Initialisez la valeur max de la bar de progression (incomplet)
  • Call Ini_Liste ' ReInitialisez la MsFlexGrid en cas de reexecution
  • If test_ip Then
  • i = Text1
  • j = Text2
  • k = Text3
  • l = Text4
  • T = Text5 & "." & Text6 & "." & Text7 & "." & Text8
  • d = i & "." & j & "." & k & "." & l
  • test = "Debut du Ping sur l'interval [" & d & " - " & T & "]."
  • refor:
  • d = i & "." & j & "." & k & "." & l
  • test = " Pinging " & d
  • Me.Refresh
  • list2.TextMatrix(x, 0) = d
  • DoEvents
  • If r = 1 Then GoTo termine
  • test = " Attente de la reponse de " & d
  • Me.Refresh
  • list2.TextMatrix(x, 2) = EasyPing(d)
  • DoEvents
  • If list2.TextMatrix(x, 2) <> "Timeout" Then suc = suc + 1
  • If r = 1 Then GoTo termine
  • If d = T Then GoTo termine1
  • If l = 255 Then
  • l = 0
  • k = k + 1
  • Else
  • l = l + 1
  • End If
  • If k = 256 Then
  • k = 0
  • j = j + 1
  • End If
  • If j = 256 Then
  • j = 0
  • i = i + 1
  • End If
  • list2.AddItem ""
  • x = x + 1
  • DoEvents
  • If r = 1 Then GoTo termine
  • GoTo refor
  • R1 = x - 1
  • termine1:
  • Call Getnom ' retrouver les noms de hote
  • termine:
  • test = " Fin Du Traitement " & g
  • R1 = x - 1
  • End If
  • End Sub
  • Private Sub Command2_Click()
  • 'Enregistrement du resultat dans un fichier
  • Load enrg
  • End Sub
  • Private Sub Command3_Click()
  • ' Buton STOP
  • r = 1
  • g = " : traitement stopper par l'utilisateur"
  • End Sub
  • Private Sub Form_Load()
  • 'Initialisation du socket + paramettres + redimentionnement
  • r = 0
  • g = ""
  • R1 = 1
  • fic = 1
  • If SocketsInitialize() Then
  • Else
  • ' GROS probleme système!
  • MsgBox "Windows Sockets for 32 bit Windows ne répond pas.", vbCritical
  • End If
  • list2.Width = 8700
  • list2.ColWidth(0) = 2000
  • list2.ColWidth(1) = 4500
  • list2.ColWidth(2) = 1800
  • list2.TextMatrix(0, 0) = "Adresse IP"
  • list2.TextMatrix(0, 1) = "Nom de l'HOTE"
  • list2.TextMatrix(0, 2) = "Reponse"
  • Command3.Enabled = False
  • End Sub
  • Private Sub Form_Unload(Cancel As Integer)
  • r = 1
  • fic = 0
  • Unload Me
  • End Sub
  • Public Function test_ip() As Boolean
  • 'Traitement des erreurs de saisie au niveaux des adresses IP
  • 'Renvoi True ou False
  • test_ip = False
  • If Text1 > Text5 Then
  • test = " Verifier les adesses : erreur T1 et T5 "
  • Exit Function
  • End If
  • If Text8 < Text4 And (Text7 < Text3 Or Text7 = Text3) Then
  • test = " Verifier les adresses : erreur T3 et T7 "
  • Exit Function
  • End If
  • If Text7 < Text3 And (Text6 < Text2 Or Text6 = Text2) Then
  • test = " Verifier les adresses : erreur T2 et T6 "
  • Exit Function
  • End If
  • If Text6 < txet2 And (Text5 < Text1 Or Text5 = Text1) Then
  • test = " Verifier les adresses : erreur T1 et T5 "
  • Exit Function
  • End If
  • If Text1 > 255 Then
  • test = "Verifier les adesses : erreur T1"
  • Exit Function
  • End If
  • If Text2 > 255 Then
  • test = "Verifier les adesses : erreur T2"
  • Exit Function
  • End If
  • If Text3 > 255 Then
  • test = "Verifier les adesses : erreur T3"
  • Exit Function
  • End If
  • If Text4 > 255 Then
  • test = "Verifier les adesses : erreur T4"
  • Exit Function
  • End If
  • If Text5 > 255 Then
  • test = "Verifier les adesses : erreur T5"
  • Exit Function
  • End If
  • If Text6 > 255 Then
  • test = "Verifier les adesses : erreur T6"
  • Exit Function
  • End If
  • If Text7 > 255 Then
  • test = "Verifier les adesses : erreur T7"
  • Exit Function
  • End If
  • If Text8 > 255 Then
  • test = "Verifier les adesses : erreur T8"
  • Exit Function
  • End If
  • Command3.Enabled = True
  • test_ip = True
  • End Function
  • Public Sub Ini_Liste()
  • ' ReInitialisez la MsFlexGrid en cas de reexecution
  • If R1 > 1 Then
  • For O = R1 To 1 Step -1
  • list2.RemoveItem (O)
  • Next
  • End If
  • list2.TextMatrix(1, 0) = ""
  • list2.TextMatrix(1, 1) = ""
  • list2.TextMatrix(1, 2) = ""
  • Command3.Enabled = True
  • End Sub
  • Public Sub Getnom()
  • ' retrouver les noms de hote
  • For F = 1 To R1 + 1
  • If list2.TextMatrix(F, 2) <> "Timeout" Then
  • test = " Resolution du nom de l'hote pour l'IP " & list2.TextMatrix(F, 0)
  • Me.Refresh
  • list2.TextMatrix(F, 1) = fGetHostName(list2.TextMatrix(F, 0))
  • DoEvents
  • If r = 1 Then Exit For
  • End If
  • Next
  • End Sub
  • Public Sub Ini_Pbar()
  • ' Initialisez la valeur max de la bar de progression
  • End Sub
Public r As Integer
Public g As String
Public R1 As Integer
Public suc As Integer

Private Sub Command1_Click()
Dim T, d As String
Dim x As Integer
Dim A1, A2, A3 As Long

test = " Debut du Ping sur l'interval [" & d & " - " & T & "]."
x = 1
suc = 0
Call Ini_Pbar  ' Initialisez la valeur max de la bar de progression (incomplet)
Call Ini_Liste ' ReInitialisez la MsFlexGrid en cas de reexecution
If test_ip Then
i = Text1
j = Text2
k = Text3
l = Text4
T = Text5 & "." & Text6 & "." & Text7 & "." & Text8
d = i & "." & j & "." & k & "." & l
test = "Debut du Ping sur l'interval [" & d & " - " & T & "]."
refor:
                
                d = i & "." & j & "." & k & "." & l
                test = " Pinging " & d
                Me.Refresh
                list2.TextMatrix(x, 0) = d
                DoEvents
                If r = 1 Then GoTo termine
                test = " Attente de la reponse de " & d
                Me.Refresh
                list2.TextMatrix(x, 2) = EasyPing(d)
                DoEvents
                If list2.TextMatrix(x, 2) <> "Timeout" Then suc = suc + 1
                If r = 1 Then GoTo termine
                If d = T Then GoTo termine1
                If l = 255 Then
                l = 0
                k = k + 1
                Else
                l = l + 1
                End If
                If k = 256 Then
                k = 0
                j = j + 1
                End If
                If j = 256 Then
                j = 0
                i = i + 1
                End If
                list2.AddItem ""
                x = x + 1
                DoEvents
                If r = 1 Then GoTo termine
                
GoTo refor
R1 = x - 1
termine1:
    Call Getnom ' retrouver les noms de hote
termine:
test = " Fin Du Traitement " & g
R1 = x - 1
End If
End Sub

Private Sub Command2_Click()
'Enregistrement du resultat dans un fichier
Load enrg
End Sub

Private Sub Command3_Click()
' Buton STOP
r = 1
g = " : traitement stopper par l'utilisateur"
End Sub

Private Sub Form_Load()
'Initialisation du socket + paramettres + redimentionnement
r = 0
g = ""
R1 = 1
fic = 1
If SocketsInitialize() Then
Else
' GROS probleme système!
   MsgBox "Windows Sockets for 32 bit Windows ne répond pas.", vbCritical
End If
list2.Width = 8700
list2.ColWidth(0) = 2000
list2.ColWidth(1) = 4500
list2.ColWidth(2) = 1800
list2.TextMatrix(0, 0) = "Adresse IP"
list2.TextMatrix(0, 1) = "Nom de l'HOTE"
list2.TextMatrix(0, 2) = "Reponse"
Command3.Enabled = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
r = 1
fic = 0
Unload Me
End Sub

Public Function test_ip() As Boolean
'Traitement des erreurs de saisie au niveaux des adresses IP
'Renvoi True ou False
test_ip = False
If Text1 > Text5 Then
test = " Verifier les adesses : erreur T1 et T5 "
Exit Function
End If
If Text8 < Text4 And (Text7 < Text3 Or Text7 = Text3) Then
test = " Verifier les adresses : erreur T3 et T7 "
Exit Function
End If
If Text7 < Text3 And (Text6 < Text2 Or Text6 = Text2) Then
test = " Verifier les adresses : erreur T2 et T6 "
Exit Function
End If
If Text6 < txet2 And (Text5 < Text1 Or Text5 = Text1) Then
test = " Verifier les adresses : erreur T1 et T5 "
Exit Function
End If
If Text1 > 255 Then
test = "Verifier les adesses : erreur T1"
Exit Function
End If
If Text2 > 255 Then
test = "Verifier les adesses : erreur T2"
Exit Function
End If
If Text3 > 255 Then
test = "Verifier les adesses : erreur T3"
Exit Function
End If
If Text4 > 255 Then
test = "Verifier les adesses : erreur T4"
Exit Function
End If
If Text5 > 255 Then
test = "Verifier les adesses : erreur T5"
Exit Function
End If
If Text6 > 255 Then
test = "Verifier les adesses : erreur T6"
Exit Function
End If
If Text7 > 255 Then
test = "Verifier les adesses : erreur T7"
Exit Function
End If
If Text8 > 255 Then
test = "Verifier les adesses : erreur T8"
Exit Function
End If
Command3.Enabled = True
test_ip = True
End Function

Public Sub Ini_Liste()
' ReInitialisez la MsFlexGrid en cas de reexecution
If R1 > 1 Then
For O = R1 To 1 Step -1
list2.RemoveItem (O)
Next
End If
list2.TextMatrix(1, 0) = ""
list2.TextMatrix(1, 1) = ""
list2.TextMatrix(1, 2) = ""
Command3.Enabled = True
End Sub

Public Sub Getnom()
' retrouver les noms de hote


For F = 1 To R1 + 1
If list2.TextMatrix(F, 2) <> "Timeout" Then
test = " Resolution du nom de l'hote pour l'IP " & list2.TextMatrix(F, 0)
Me.Refresh

list2.TextMatrix(F, 1) = fGetHostName(list2.TextMatrix(F, 0))
DoEvents
If r = 1 Then Exit For
End If
Next
End Sub

Public Sub Ini_Pbar()
' Initialisez la valeur max de la bar de progression


End Sub

Conclusion

2 adresses IP sans les points dans 4 case pour chaqu'une (8 cases a remplir).

Merci de me soumettre vos suggestions.
 

Fichier Zip

Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

Commentaires et avis

signaler à un administrateur
Commentaire de FrostByte le 16/08/2004 10:45:37

Source doublon !!! il me semble

signaler à un administrateur
Commentaire de ITALIA le 17/08/2004 09:19:56

pas tout a fait....l'un saute une adresse sur 2 je crois..

signaler à un administrateur
Commentaire de DeadlyPredator le 18/08/2004 01:03:24

Le fait d'utiliser call <fonction> est plus lent que de faire <fonction> simplement

signaler à un administrateur
Commentaire de jdir le 31/03/2006 17:27:30

pas mal mais je vous encourage  

Ajouter un commentaire



Nos sponsors

Sondage...

CalendriCode

Janvier 2009
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

Consulter la suite du CalendriCode



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel BAÏSE, Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,296 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.