Results 1 to 2 of 2

Thread: [2008] Clear radiobuttons in groupbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2008
    Posts
    1

    [2008] Clear radiobuttons in groupbox

    Hi there,

    Basically, my form has 5 groupboxes with 4 radiobuttons in each groupbox, and I also have 3 textboxes. I have a button in the form in which I can go back to the main screen, and likewise, a button in the main screen to go back to this form.

    So when I select the radiobuttons in the groupboxes, and i clicked the main screen, and back to the form, it will clear all selections, including the textboxes. I was able to do that, but if I didn't select any of the radiobuttons, and I clicked the main screen button, it will have an error. "Object reference not set to an instance of an object."

    Code:
     Me.RadioButtons.Checked = False
            Me.RadioButtons1.Checked = False
            Me.RadioButtons2.Checked = False
            Me.RadioButtons3.Checked = False
            Me.RadioButtons4.Checked = False
    This is part of my code in the Main Screen button.

    Any idea how? Thanks.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Clear radiobuttons in groupbox

    That error message has nothing to do with that code. When the exception is thrown the IDE will tell you exactly what line the exception was thrown on. You then need to use the debugger to test each reference on that line to see which is null, i.e. Nothing. You then need to work back through your code to the point where you expected an object to be assigned to that reference and determine why it wasn't.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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