wahidovic
Messages postés11Date d'inscriptionvendredi 22 avril 2011StatutMembreDernière intervention20 mai 2012
-
15 avril 2012 à 15:17
cs_ShayW
Messages postés3253Date d'inscriptionjeudi 26 novembre 2009StatutMembreDernière intervention 3 décembre 2019
-
15 avril 2012 à 17:21
bonjour j'ai constitué une structure publique qui contient deux tableau tableau que je veux remplir a l'aide d'une fonction mais le compilateur m'affiche cette erreur
"l'exception NullReferencesException n'a pas été géré" , "la reference d'objet n'est pas definie a une instance d'objet"
voici ma structure
Public Structure information
Dim tentatives As Integer
Dim operateurs As String
Dim country As String
Dim int_outband As String
Dim succes As String
Dim type_erreur() As String
Dim nombre_erreur() As Integer
Dim origines As String
Dim destinations As String
Dim tcapops As String
End Structure
j'ai fait un module afin de déclarer ma structure publique
Module declaration_globale
Public tableau_structure As New List(Of information)
End Module
après il y a un programme principale qui fait appel a la fonction suivante et dans laquelle figure l'erreur
Public Sub chercher_operateur_end_erreur(ByVal origine As String, ByVal destination As String, ByVal tcap_error As String, ByVal appl_context As String, ByVal tcap As String)
Dim flag_erreur As Boolean = False
Dim fifi As New information
For k = 0 To tableau_structure.Count - 1
If tableau_structure(k).operateurs fifi.operateurs And tableau_structure(k).country fifi.country And tableau_structure(k).int_outband = fifi.int_outband Then
fifi.nombre_erreur = tableau_structure(k).nombre_erreur
fifi.type_erreur = tableau_structure(k).type_erreur
' l'erreur commence a partir de la ligne ci dessous
For h As Integer = 0 To tableau_structure(k).nombre_erreur.Length - 1
If tcap_error = tableau_structure(k).type_erreur(h) Then
fifi.nombre_erreur(h) = tableau_structure(k).nombre_erreur(h) + 1
tableau_structure.Remove(tableau_structure(k))
tableau_structure.Insert(k, fifi)
flag_erreur = True
End If
Next
If flag_erreur = False Then
'je cree une nouvelle case dans les deux tableau
fifi.nombre_erreur(tableau_structure(k).nombre_erreur.Length + 1) = 1
fifi.type_erreur(tableau_structure(k).type_erreur.Length + 1) = tcap_error
tableau_structure.Remove(tableau_structure(k))
tableau_structure.Insert(k, fifi)
End If
End If
Next
End Sub
cs_ShayW
Messages postés3253Date d'inscriptionjeudi 26 novembre 2009StatutMembreDernière intervention 3 décembre 201957 15 avril 2012 à 15:43
Salut
déja pas compris ton if
If tableau_structure(k).operateurs = fifi.operateurs
fifi.operateurs n'as aucune valeur soit il est
vide string empty
tu as crée une instance de ta structure information mais tu n'as assigné aucune valeur
wahidovic
Messages postés11Date d'inscriptionvendredi 22 avril 2011StatutMembreDernière intervention20 mai 2012 15 avril 2012 à 16:19
j'ai pas copié toute la fonction en réalité !!
Public Sub chercher_operateur_end_erreur(ByVal origine As String, ByVal destination As String, ByVal tcap_error As String, ByVal appl_context As String, ByVal tcap As String)
Dim flag_erreur As Boolean = False
Dim fifi As New information
Dim oper() As String
Dim k As Integer = 4
Dim flag_3 As Boolean = False
oper = File.ReadAllLines("movistar.csv")
Dim oper_frac As String()
Dim flag As Boolean = False
If origine.Contains("`21377") Then
fifi.int_outband = "outbound"
Else
Do
For n As Integer = 0 To oper.Length - 1
oper_frac = oper(n).Split(";")
If origine.Contains(Mid(oper_frac(0), 1, k)) Then
fifi.operateurs = oper_frac(2)
fifi.country = oper_frac(3)
flag = True
End If
Next
k = k + 1
Loop Until flag True Or k 8
End If
If destination.Contains("`21377") Then
fifi.int_outband = "inbound"
Else
Do
For n As Integer = 0 To oper.Length - 1
oper_frac = oper(n).Split(";")
If destination.Contains(Mid(oper_frac(0), 1, k)) Then
fifi.operateurs = oper_frac(2)
fifi.country = oper_frac(3)
flag = True
End If
Next
k = k + 1
Loop Until flag True Or k 8
End If
'tout ce travail la afin de chercher l’opérateur, son pays et in ou outbound .
maintenant je vais réviser ma liste de structure construite dans le programme principale , si cet opérateurs existe déjà dans l'une de mes structure alors je vais chercher l'erreur qui est "tcap_error" en paramétrés dans cette fonction dans le TABLEAU DE LA STRUCTURE en question (type_erreur) si je le trouve j’incrémente le nombre d'erreur dans le 2eme TABLEAU DE LA STRUCTURE (nombre_erreur) si je ne trouve pas cette erreur j'elargie mon tableau d'une case qui va contenir le type d'erreur et le 2eme tableau d'une case qui va contenir le nombre d'erreur qui sera egal a "1" dans mon cas
For k = 0 To tableau_structure.Count - 1
If tableau_structure(k).operateurs fifi.operateurs And tableau_structure(k).country fifi.country And tableau_structure(k).int_outband = fifi.int_outband Then
fifi.nombre_erreur = tableau_structure(k).nombre_erreur
tab_numbre = fifi.nombre_erreur
fifi.type_erreur = tableau_structure(k).type_erreur
tab_type = fifi.type_erreur
For h As Integer = 0 To tableau_structure(k).nombre_erreur.Length - 1
If tcap_error = tableau_structure(k).type_erreur(h) Then
fifi.nombre_erreur(h) = tableau_structure(k).nombre_erreur(h) + 1
fifi.succes = tableau_structure(k).succes
fifi.tentatives = tableau_structure(k).tentatives
fifi.operateurs = tableau_structure(k).operateurs
fifi.country = tableau_structure(k).country
fifi.int_outband = tableau_structure(k).int_outband
tableau_structure.Remove(tableau_structure(k))
tableau_structure.Insert(k, fifi)
flag_erreur = True
End If
Next
If flag_erreur = False Then
'je cree une nouvelle case dans les deux tableau
fifi.nombre_erreur(tableau_structure(k).nombre_erreur.Length + 1) = 1
fifi.type_erreur(tableau_structure(k).type_erreur.Length + 1) = tcap_error
fifi.succes = tableau_structure(k).succes
fifi.tentatives = tableau_structure(k).tentatives
fifi.operateurs = tableau_structure(k).operateurs
fifi.country = tableau_structure(k).country
fifi.int_outband = tableau_structure(k).int_outband
tableau_structure.Remove(tableau_structure(k))
tableau_structure.Insert(k, fifi)
End If
End If
Next
End Sub