Solved

Sudden error but not sure why with group box

Posted on 2014-02-24
3
190 Views
Last Modified: 2014-02-24
I have the  following code, that all of a sudden doesn't work.   Not sure why.  Here is the code.  This code was working, could it have something to do with the button not being filled correctly?

error received

Here is the error.

Private Sub cmdEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEnter.Click

        Dim myButton As New RadioButton
        Dim isSelected As Boolean = False
        Try
            If gbBedRooms.Visible = True Then
                For Each myButton In gbBedRooms.Controls
                    If myButton.Checked = True Then
                        mSelectedGroup = myButton.Text
                        isSelected = True
                        Exit For
                    Else
                    End If
                Next
                If isSelected = False Then
                    MsgBox("Please select room")
                    Exit Sub
                Else
                End If
            ElseIf gbBathrooms.Visible = True Then
                For Each myButton In gbBathrooms.Controls
                    If myButton.Checked = True Then
                        mSelectedGroup = myButton.Text
                        isSelected = True
                        Exit For
                    Else
                    End If
                Next
                If isSelected = False Then
                    MsgBox("Please select room")
                    Exit Sub
                Else
                End If
            ElseIf gbCommon.Visible = True Then
                For Each myButton In gbCommon.Controls
                    If myButton.Checked = True Then
                        mSelectedGroup = myButton.Text
                        isSelected = True
                        Exit For
                    Else
                    End If
                Next
                If isSelected = False Then
                    MsgBox("Please select room")
                    Exit Sub
                Else
                End If
            Else
                mSelectedGroup = mSelectedTab
            End If


            'If Not ValidateForm() Then
            '    Exit Sub

            'Else
            '    Dim myInspection As New frmTabControl
            '    myInspection.Tag = "New"
            '    myInspection.ShowDialog()
            'End If
            Me.DialogResult = Windows.Forms.DialogResult.OK
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


    End Sub
0
Comment
Question by:mgmhicks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Author Comment

by:mgmhicks
ID: 39882987
Sorry its erroring when it hits

For Each myButton In gbBathrooms.Controls
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 39883079
Change all of these:

    For Each myButton In gbBedRooms.Controls

To:

    For Each myButton In gbBedRooms.Controls.OfType(Of RadioButton)()
0
 

Author Closing Comment

by:mgmhicks
ID: 39883260
That will do it, turns out had another tab inside a tab so with my code it would error, and why all of a sudden it started to error.  With your code it would of never recieved the error.



thanks
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question