Matching the values of Split string in if condition

亡梦爱人 提交于 2020-01-25 08:44:24

问题


What I'm trying to achieve is to match the Source doc no. of PER SAWT to PER MAP.
If it matches it will automatically check the CheckBox and it will set the BackColor to Color.Yellow.

But when I try to split the Source Doc in PER MAP, it will only get the 2nd Value which is BS091 as per screenshot in 1st Scenario.

My code work in 2nd scenario.

1st Scenario

2nd Senario

Here is the code:

For x As Integer = 0 To Me.DataGridView4.Rows.Count - 1
    Dim sdoc_sawt As String = DataGridView4.Rows(x).Cells("Source_Doc_No").Value.ToString
    'Sample Value: "RR0022/BS091/BS092/BS093"

    Dim sdoc_map As String = DataGridView4.Rows(x).Cells("Source_Doc_No_P").Value.ToString
    Dim split_sdoc As String() = sdoc_map.Split("/")

    Dim part As String
    For Each part In split_sdoc
         If Me.DataGridView4.Rows(x).Cells("Source_Doc_No").Value.ToString = part Then

            Me.DataGridView4.Rows(x).Cells(0) = New DataGridViewCheckBoxCell With {.Value = True}

            '-------Will automatically color the yellow of math Source Docu no.----------'
            Me.DataGridView4.Rows(x).Cells(0).Style.BackColor = Color.Yellow
            Me.DataGridView4.Rows(x).Cells("Source_Doc_No").Style.BackColor = Color.Yellow
            Me.DataGridView4.Rows(x).Cells("ATC").Style.BackColor = Color.Yellow
            Me.DataGridView4.Rows(x).Cells("Prepaid_Tax").Style.BackColor = Color.Yellow
            Me.DataGridView4.Rows(x).Cells("Source_Doc_No_P").Style.BackColor = Color.Yellow
            Me.DataGridView4.Rows(x).Cells("ATC_P").Style.BackColor = Color.Yellow
            Me.DataGridView4.Rows(x).Cells("Tax_Withheld_P").Style.BackColor = Color.Yellow
            '-----------------------------------End---------------------------------------'
        End If
    Next
Next

来源:https://stackoverflow.com/questions/53735905/matching-the-values-of-split-string-in-if-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!