Solved

Sudden error but not sure why with group box

Posted on 2014-02-24
3
189 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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