Thanks SO much to Archie and Bachpie for tutoring me a little. I now have an AdvancedHMI with a single button. All my Visual Basic code is in the button routine. When you push the button it reads two arrays of 400 integers from the RsLogix PLC and writes them into an existing spreadsheet HistogramData.xlsx (overwriting the previous data). I have a second spreadsheet that links to HistogramData and charts and analyses it.
My code looks like this:
Private Sub BasicButton1_Click(sender As Object, e As EventArgs) Handles BasicButton1.Click
Dim Hist500Data() As String = EthernetIPforCLXCom1.Read("Histogram500[0]", 400)
Dim Hist1000Data() As String = EthernetIPforCLXCom1.Read("Histogram1000[0]", 400)
Dim StrNumber As String
Dim filepath As String = ".\HistogramData.xlsx"
Using WB As New ClosedXML.Excel.XLWorkbook(filepath)
For i As Integer = 0 To Hist500Data.GetLength(0) - 1
If IsNumeric(Hist500Data(i)) Then
WB.Worksheet(1).Cell(i + 2, 2).Value = CInt(Hist500Data(i))
Else WB.Worksheet(1).Cell(i + 2, 2).Value = 0
End If
If IsNumeric(Hist1000Data(i)) Then
WB.Worksheet(1).Cell(i + 2, 3).Value = CInt(Hist1000Data(i))
Else WB.Worksheet(1).Cell(i + 2, 3).Value = 0
End If
Next
WB.Save()
End Using
End Sub