?
Solved

Sudden error but not sure why with group box

Posted on 2014-02-24
3
Medium Priority
?
192 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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