Weird bug

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Harry

    #1

    Weird bug

    Hi All

    I have this weird bug in the code below:

    Dim temp As String = oAction.ActionT ype.ToString

    For Each ctl As Control In Me.Controls

    If ctl.Tag IsNot Nothing Then

    ctl.Visible = ctl.Tag.ToStrin g.Contains(temp ) '<------error here

    ctl.Enabled = ctl.Visible

    End If

    Next

    The error is: IndexOutOfRange Exception (Index -1 does not have a value)

    I have a number of controls on the form that are visible depending on the
    value I put in the tag property




  • Cor Ligthert[MVP]

    #2
    Re: Weird bug

    Harry,

    What is me, if that does not contain a control, then your result will be -1
    that is not a bug, you have to test before that.

    However don't ask here with bugs about your program, we see bugs as bugs in
    Visual Studio and then become confused.

    Thank you in advance.

    Cor

    Comment

    Working...