Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. problem when open image from file

problem when open image from file

Scheduled Pinned Locked Moved Visual Basic
helpgame-dev
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    campbells
    wrote on last edited by
    #1

    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

    S C 2 Replies Last reply
    0
    • C campbells

      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

      S Offline
      S Offline
      Swammingo
      wrote on last edited by
      #2

      hi, I think ... if you are getting a problem with only one .png file then it might be that the file format is unrecognised.or the image file is missing.... Apart from that i dont think there shud be any problem. Hope it helps ... bye:)

      1 Reply Last reply
      0
      • C campbells

        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

        C Offline
        C Offline
        Chatura Dilan
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • C 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

          C Offline
          C Offline
          campbells
          wrote on last edited by
          #4

          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 ?

          C 1 Reply Last reply
          0
          • C campbells

            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 ?

            C Offline
            C Offline
            Chatura Dilan
            wrote on last edited by
            #5

            Can you explain it more? Chatura Dilan

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups