Solved

Sudden error but not sure why with group box

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

24 Experts available now in Live!

Get 1:1 Help Now