Menu

Help with line of code

Help
2011-09-19
2013-05-30
  • aaron tanquerel

    aaron tanquerel - 2011-09-19

    Hi,

    I'm using this code:

    textbox1.lines = Me.Controls.OfType(Of Box).Select(Function(b) b.PLCaddress).Reverse.ToArray

    to get the plc addresses from all of my controls, however, when i run it in advancedHMI i get this error:

    'oftype' is not a member of 'system.windows.forms.control.controlcollection'.

    Any ideas, thanks?

     
  • Archie

    Archie - 2011-09-19

    Not sure about that method, but this is one way using a ListBox that may give you what you want:

            For Each x As Object In Me.Controls
                Try
                    ListBox1.Items.Add(x.plcAddressText)
                Catch ex As Exception
                End Try
                Try
                    ListBox1.Items.Add(x.plcAddressValue)
                Catch ex As Exception
                End Try
            Next

     
  • aaron tanquerel

    aaron tanquerel - 2011-09-20

    That's what i was trying to do!  But, now, i'd like to get each control listed out into separate arrays, say filtering by DigitalMeter, Gauge etc?

    I tried this but it didn't work:

    For Each DigitalMeter As Object In Me.Controls
                Try
                    ListBox1.Items.Add(DigitalMeter.plcAddressText)
                Catch ex As Exception
                End Try
                      Next
    It just gives me all of the controls in one go?

     

Log in to post a comment.