Author Topic: Change multi colors by value  (Read 1462 times)

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Change multi colors by value
« on: January 22, 2021, 03:58:36 AM »
Hi,

im trying to change colors of basic shape by value. I added basic shapes to form and datasubscriber and add some PLCAddressValueItems (D125,D126), but doesnt work.

Thats my code

Code: [Select]
Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged

        If e.PlcAddress = "D125" = "0" Then
            BasicShape1.BackColor = Color.LightGray

        ElseIf e.PlcAddress = "D125" = "1" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 220)

        ElseIf e.PlcAddress = "D125" = "2" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 170)

        ElseIf e.PlcAddress = "D125" = "3" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 120)

        ElseIf e.PlcAddress = "D125" = "4" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 50)

        ElseIf e.PlcAddress = "D126" = "0" Then
            BasicShape2.BackColor = Color.LightGray

        ElseIf e.PlcAddress = "D126" = "1" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 220)

        ElseIf e.PlcAddress = "D126" = "2" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 170)

        ElseIf e.PlcAddress = "D126" = "3" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 120)

        ElseIf e.PlcAddress = "D126" = "4" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 50)

        End If

    End Sub

betilly

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Change multi colors by value
« Reply #1 on: January 22, 2021, 05:11:43 AM »
It looks like i need just make new post, and after that in little or no time find the solution. Just changed code a little bit and voila, works.

Code: [Select]
Private Sub DataSubscriber21_DataChanged(sender As Object, e As Drivers.Common.PlcComEventArgs) Handles DataSubscriber21.DataChanged

        If e.PlcAddress = "D125" And e.Values(0) = "0" Then
            BasicShape1.BackColor = Color.LightGray

        ElseIf e.PlcAddress = "D125" And e.Values(0) = "1" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 220)

        ElseIf e.PlcAddress = "D125" And e.Values(0) = "2" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 170)

        ElseIf e.PlcAddress = "D125" And e.Values(0) = "3" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 120)

        ElseIf e.PlcAddress = "D125" And e.Values(0) = "4" Then
            BasicShape1.BackColor = Color.FromArgb(255, 255, 50)

        ElseIf e.PlcAddress = "D126" And e.Values(0) = "0" Then
            BasicShape2.BackColor = Color.LightGray

        ElseIf e.PlcAddress = "D126" And e.Values(0) = "1" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 220)

        ElseIf e.PlcAddress = "D126" And e.Values(0) = "2" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 170)

        ElseIf e.PlcAddress = "D126" And e.Values(0) = "3" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 120)

        ElseIf e.PlcAddress = "D126" And e.Values(0) = "4" Then
            BasicShape2.BackColor = Color.FromArgb(255, 255, 50)

        End If

    End Sub