Tom's Guide > Forum > Programmation > Message d'erreur dans une application vb.net
Mot :    Pseudo :           
 

Bonjour tout le monde,
j'ai un message d'erreur concernant l'instanciation d'un objet:

System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet. à PoMailPh.frmPrinc.procVerifFichier() à PoMailPh.frmPrinc.fct_watch_folder()

Suite a des recherches, j'ai su que ca se regle par new mais je vois pas ou je peux l'integrer et de quel objet il s'agit dans cette partie de code.

Code :
  1. Private Sub procVerifFichier()
  2.         Dim i As Integer
  3.         Dim sFiles() As String
  4.         Dim FreeF As Integer
  5.         Dim str() As String
  6.         Dim tmp() As String
  7. Do
  8.             Try
  9.                 'System.Threading.Thread.Sleep(5000)
  10.                 If Not File.Exists(f_in & "\pomail.lock" ) Then
  11.                     'pour avoir les noms des fichiers et des sous-répertoires
  12.                     sFiles = Directory.GetFiles(f_in)
  13.                     For i = 0 To sFiles.GetUpperBound(0)
  14.                         If InStr(sFiles(i), ".txt" ) > 0 Then
  15.                             'System.Threading.Thread.Sleep(5000)
  16.                             FreeF = FreeFile()                                            'Possibilité de mettre 1************
  17.                             FileOpen(FreeF, sFiles(i), OpenMode.Input)                  'Ouverture du fichier créé**********
  18.                             str = Split(InputString(FreeF, FileLen(sFiles(i))), Chr(10)) 'Séparation des lignes du fichier***
  19.                             FileClose(FreeF)
  20.                             File.Delete(archive & sFiles(i).Substring(27, sFiles(i).Length - 27))
  21.                             File.Move(sFiles(i), archive & sFiles(i).Substring(27, sFiles(i).Length - 27))
  22.                             'MsgBox(sFiles(i), archive & sFiles(i))
  23.                             With txtwatch
  24.                                 .SelectionStart = Len(txtwatch.Text)
  25.                                 .SelectionProtected = False
  26.                                 .SelectionStart = Len(txtwatch.Text) + 1
  27.                                 .SelectionColor = System.Drawing.Color.Red
  28.                                 .SelectedText = "Fichier créé : " & Replace(sFiles(i), f_in, "" ) & " " & Date.Now & vbCrLf
  29.                                 .SelectionProtected = True
  30.                                 .Focus()
  31.                                 .SelectionStart = txtwatch.Text.Length
  32.                                 .ScrollToCaret()
  33.                             End With
  34.                             tmp = Split(Replace(Replace(str(0), Chr(34), "" ), "'", " " ), ";" )
  35.                             'If tmp(2).ToUpper <> "V" Then
  36.                             'Exit Sub
  37.                             'end if
  38.                             If tmp(2).ToUpper = "V" Then
  39.                                 fct_fill_sql(str, sFiles(i).Substring(27, 2).ToUpper)
  40.                                 fct_fill_excel(str, sFiles(i).Substring(27, 2).ToUpper)
  41.                             End If
  42.                         End If
  43.                         If File.Exists(f_in & "\pomail.lock" ) Then Exit For
  44.                     Next
  45.                 End If
  46.             Catch ex As Exception
  47.                 fct_send_mail(envoyeur, warning, "ERREUR PO VIA MAIL " & Replace(sFiles(i), f_in, "" ), 0, ex.ToString, "none" )
  48.                 '# erreur no 1
  49.                 fct_exec_sql("UPDATE pur_order SET err=1 WHERE pur_order.po_number='0'" )
  50.             End Try
  51.             Exit Do
  52.         Loop
  53.     End Sub


dans .fct_watch_folder(), j'appelle la fonction procVerifFichier().
Merci beaucoup pour votre aide.

Liens sponsorisés
Inscrivez-vous ou connectez-vous pour masquer ceci.
Tom's Guide > Forum > Programmation > Message d'erreur dans une application vb.net
Aller à :

Il y a 943 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici.

Attention

Vous allez répondre sur un sujet resté inactif pendant plus de 6 mois.
Assurez-vous d'apporter des éléments nouveaux à la discussion avant de poursuivre.

Répondre Annuler
Liens