Solved

Sudden error but not sure why with group box

Posted on 2014-02-24
3
187 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
  • 2
3 Comments
 

Author Comment

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

For Each myButton In gbBathrooms.Controls
0
 
LVL 85

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now