Results 1 to 12 of 12

Thread: Faulty Code

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Faulty Code

    I have a project which is almost fully working, it merely has one little bug that needs to be removed. I would post the code for the project, but that's a bit too big to post, but if someone wanted to see it, I am more than happy to share it if it leads to them being able to help me fix this bug.

    I have writting psudo-code for this bug below:

    Code:
    (On load)
    If (users.csv != Exist)
    {
      Show Form3; // Gather username and filename
    }
    Elseif (users.csv == Exist)
    {
      Show Form2; // List all users and files
      If (UseSelected == Clicked)
      {
        CurrentCSVfile = xyz; // Works fine
      }
      Elseif (Createnew == Clicked)
      {
        Show Form3; // Here is where the problems arrise
        CurrentCSVfile = xyz;
      }
    }
    Overall, the program reads up question and answer csv files giving the user multiple choice questions. Their results are then stored in their account file, which is what this startup procedure is for, as shown above in the psudo-code, where CurrentCSVfile is the file which the current user's answers are stored in.

    If there are no users, the program gets the user to make one - works fine
    If one or more users already exist, the user is to select one from a list or create a new one - select from a list works fine, but creating a new one does not, and returns errors.

    Any ideas?

    Cheers.

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Faulty Code

    I could choose to be very sarcastic about the fact that I am not able to read minds, but its been done to death. So stop messing around and tell us what errors you get and post your code too.

    (Pseudocode is useless for debugging, nobody minds if its in C# .)
    I don't live here any more.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: Faulty Code

    The actual error is:

    An unhandled exception of type 'System.NummReferenceException' occurred
    in QuestionMachineVB.exe

    Additional information: Object reference not set to an instance of an object.

    [BREAK] [Continue]
    I click continue and the app moves it's cursor to Line 879 in Form1.vb which is

    Code:
    questionEnumerator.Reset()
    You can download the code from:

    www.cyber-lane.com/code.zip


    If you can come up with any solutions, please let me know. This is way past it's deadline as I've been off ill for the last week...

    :-/

    Cheers.

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Faulty Code

    You have not initialized the object. thats what "NullReference" means, you have declared the object but it has not yet been set to refer to an instance of the class.
    I don't live here any more.

  5. #5
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: Faulty Code

    You have to use the "new" somewhere...
    Godwin

    Help someone else with what someone helped you!

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Faulty Code

    not necessarily

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: Faulty Code

    All this winking and no pointing me at the right form/line of code, other than the "NullReference" info wossname posted...


  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Faulty Code

    VB Code:
    1. Public Sub New()
    2.             MyBase.New()
    3.  
    4.             Application.EnableVisualStyles()
    5.             'This call is required by the Windows Form Designer.
    6.             InitializeComponent()
    7.             InitializeCustomComponent()
    8.  
    9.             'Add any initialization after the InitializeComponent() call
    10.  
    11.     [B]questionEnumerator = gt.GetEnumerator()[/B] '### add this line ###
    12.  
    13.         End Sub
    I don't live here any more.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: Faulty Code

    Where do I shove this code wossname?

    As up on line 804 (or possibly 805 on the code I uploaded as I removed a comment)

    questionEnumerator = gt.GetEnumerator()

    is already present. Or am I to create another instance of it?

  10. #10
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Faulty Code

    your problem is that you are trying to use the object before it initialised. Initialising it in the constructor pre-empts all calls to the object itself. Therefore its always ready for action.
    I don't live here any more.

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: Faulty Code

    OK, I added that in, and now my error has changed:

    An unhandled exception of type 'System.InvalidOperationException'
    occurred in mscorlib.dll

    Additional information: Enumeration already finished.

    [Break] [Continue]
    And now when I click Continue, my cursor is moved to line 208 in GenericTree.vb, which is:

    Code:
    Public ReadOnly Property Current() As Object Implements IEnumerator.Current
      Get
        Return underlying Enumerator.Current
      End Get
    End Property
    Any ideas on how to fix my main problem though, as I am sure it is just something missing, or just something else needs adding...


  12. #12

    Thread Starter
    Lively Member
    Join Date
    Jul 2005
    Location
    England
    Posts
    79

    Re: Faulty Code

    Nothing??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width