L'exception System.NullReferenceException n'a pas été gérée
Bonjour a tous.
Je ne sais pas si mon idée marche mais pour regrouper 4 images en une seulle je dessine a l'interieur d'une pucture box(picturebox1) 4 picture boxe(picturebox2,picturebox3,picturebox4,picturebox5) et je veux ensuite sauvegarder ma pictureboxe contenant les 4 picture box
malheureusement sur les derniéres lignes
Kill(az) j'ai une erreur a l'exécution :
Citation:
L'exception System.IO.IOException n'a pas été gérée
PictureBox1.Image.Save(az, ImageFormat.Jpeg) une erreur a l'exécution :
Citation:
L'exception System.NullReferenceException n'a pas été gérée
je ne vois pas d'où cela peut provenir ,pourriez vous me venir en aide?
Je vous en remercie par avance
voici mon code
Code:
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.IO
Imports System.IO.Path
Imports VB = Microsoft.VisualBasic
Imports System.Windows.Forms.ListBox
Imports System.Drawing
Imports System.Drawing.Imaging
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' charger image dans picturebox2
Dim zz = "E:\VBESSAIPICTUREBOX\VBESSAIPICTURE\VBESSAIPICTURE\bin\Debug\DATA\A.jpg"
Dim fs As System.IO.FileStream
' Specify a valid picture file path on your computer.
fs = New System.IO.FileStream(zz, IO.FileMode.Open, IO.FileAccess.Read)
PictureBox2.Image = System.Drawing.Image.FromStream(fs)
fs.Dispose()
fs = Nothing
'***********************************
' charger image dans picturebox3
zz = "E:\VBESSAIPICTUREBOX\VBESSAIPICTURE\VBESSAIPICTURE\bin\Debug\DATA\B.jpg"
' Specify a valid picture file path on your computer.
fs = New System.IO.FileStream(zz, IO.FileMode.Open, IO.FileAccess.Read)
PictureBox3.Image = System.Drawing.Image.FromStream(fs)
fs.Dispose()
fs = Nothing
'***********************************
' charger image dans picturebox4
zz = "E:\VBESSAIPICTUREBOX\VBESSAIPICTURE\VBESSAIPICTURE\bin\Debug\DATA\B.jpg"
' Specify a valid picture file path on your computer.
fs = New System.IO.FileStream(zz, IO.FileMode.Open, IO.FileAccess.Read)
PictureBox4.Image = System.Drawing.Image.FromStream(fs)
fs.Dispose()
fs = Nothing
'***********************************
' charger image dans picturebox5
zz = "E:\VBESSAIPICTUREBOX\VBESSAIPICTURE\VBESSAIPICTURE\bin\Debug\DATA\C.jpg"
' Specify a valid picture file path on your computer.
fs = New System.IO.FileStream(zz, IO.FileMode.Open, IO.FileAccess.Read)
PictureBox5.Image = System.Drawing.Image.FromStream(fs)
fs.Dispose()
fs = Nothing
'***********************************
'***********************************
PictureBox1.Invalidate()
Me.Refresh()
Dim az = "E:\VBESSAIPICTUREBOX\VBESSAIPICTURE\VBESSAIPICTURE\bin\Debug\DATA\A.jpg"
' az = "E:\aa.jpg"
Kill(az)
PictureBox1.Image.Save(az, ImageFormat.Jpeg)
End Sub
End Class |
L'exception System.NullReferenceException n'a pas été gérée
Re bonsoir a tous.
pour la ligne
Kill(az)
j'ai resolu par
Code:
1 2 3
| if file.existe(az)
kill(az)
end if |
j'ai mofifi" ma seconde ligne
Code:
PictureBox1.Image.Save(az, ImageFormat.Jpeg)
par
Code:
PictureBox1.Image.Save(az)
l'erreur a l'exécution est :
Citation:
L'exception System.NullReferenceException n'a pas été gérée
merci a tous ceux qui pourront m'aider