problem when open image from file
-
i encounted this problem while runing my system An unhandled exception of type 'System.NullReferenceException' occurred in Snake&LadderGame.exe Object reference not set to an instance of an object. the error line was at "game.P1.Image = Image.FromFile(imagetoken)" i have try use break point go through it.. the system did run through those coding and get the value...wonder how come cannnot pass the image.. --------function 'Loading picture from folder If y = 1 Then imagetoken = (Path.GetDirectoryName(Application.ExecutablePath) & "\tokenimage\1egg.png") ElseIf y = 2 Then imagetoken = (Path.GetDirectoryName(Application.ExecutablePath) & "\tokenimage\2egg.png") ElseIf y = 3 Then ........ End If If c = 1 Then game.P1.Image = Image.FromFile(imagetoken) game.Player1.Image = Image.FromFile(imagetoken) ElseIf c = 2 Then game.P2.Image = Image.FromFile(imagetoken) game.Player2.Image = Image.FromFile(imagetoken) ElseIf c = 3 Then game.P3.Image = Image.FromFile(imagetoken) game.Player3.Image = Image.FromFile(imagetoken) ElseIf c = 4 Then game.P4.Image = Image.FromFile(imagetoken) game.Player4.Image = Image.FromFile(imagetoken) End If -- modified at 3:36 Tuesday 28th March, 2006
-
i encounted this problem while runing my system An unhandled exception of type 'System.NullReferenceException' occurred in Snake&LadderGame.exe Object reference not set to an instance of an object. the error line was at "game.P1.Image = Image.FromFile(imagetoken)" i have try use break point go through it.. the system did run through those coding and get the value...wonder how come cannnot pass the image.. --------function 'Loading picture from folder If y = 1 Then imagetoken = (Path.GetDirectoryName(Application.ExecutablePath) & "\tokenimage\1egg.png") ElseIf y = 2 Then imagetoken = (Path.GetDirectoryName(Application.ExecutablePath) & "\tokenimage\2egg.png") ElseIf y = 3 Then ........ End If If c = 1 Then game.P1.Image = Image.FromFile(imagetoken) game.Player1.Image = Image.FromFile(imagetoken) ElseIf c = 2 Then game.P2.Image = Image.FromFile(imagetoken) game.Player2.Image = Image.FromFile(imagetoken) ElseIf c = 3 Then game.P3.Image = Image.FromFile(imagetoken) game.Player3.Image = Image.FromFile(imagetoken) ElseIf c = 4 Then game.P4.Image = Image.FromFile(imagetoken) game.Player4.Image = Image.FromFile(imagetoken) End If -- modified at 3:36 Tuesday 28th March, 2006
-
i encounted this problem while runing my system An unhandled exception of type 'System.NullReferenceException' occurred in Snake&LadderGame.exe Object reference not set to an instance of an object. the error line was at "game.P1.Image = Image.FromFile(imagetoken)" i have try use break point go through it.. the system did run through those coding and get the value...wonder how come cannnot pass the image.. --------function 'Loading picture from folder If y = 1 Then imagetoken = (Path.GetDirectoryName(Application.ExecutablePath) & "\tokenimage\1egg.png") ElseIf y = 2 Then imagetoken = (Path.GetDirectoryName(Application.ExecutablePath) & "\tokenimage\2egg.png") ElseIf y = 3 Then ........ End If If c = 1 Then game.P1.Image = Image.FromFile(imagetoken) game.Player1.Image = Image.FromFile(imagetoken) ElseIf c = 2 Then game.P2.Image = Image.FromFile(imagetoken) game.Player2.Image = Image.FromFile(imagetoken) ElseIf c = 3 Then game.P3.Image = Image.FromFile(imagetoken) game.Player3.Image = Image.FromFile(imagetoken) ElseIf c = 4 Then game.P4.Image = Image.FromFile(imagetoken) game.Player4.Image = Image.FromFile(imagetoken) End If -- modified at 3:36 Tuesday 28th March, 2006
I don’t find any errors in your code, but make sure that you declare your game form correctly with New keyword. Like
Dim game As **New** Form2
Chatura Dilan -
I don’t find any errors in your code, but make sure that you declare your game form correctly with New keyword. Like
Dim game As **New** Form2
Chatura Dilan -
actually it able to work for my perviuos form, but when i try to put it in here it woundnt work, will it becasuse the other form having the same function ?
Can you explain it more? Chatura Dilan