想实现不重复添加主键值,作为主表和子表的关联字段(2个表没有用自动编号字段来关联)
如主表的“主键”字段存储了: 40281,40430,40520,40685,40972,41284,41173,41284 。
其中的数字为子表的主键。
如何判断某个主键是否存在于该字符串内?
比如 4043就不存在,但40430就存在。
dim s as string = "
40281,40430,40520,40685,40972,41284,41173,41284"
s = "," & s & ","
msgbox(s.contains(",4043,"))
msgbox(s.contains(",40430,"))
之前我是想用split将字符串分割成数组,
但分割后,我用contais或者indexof 来判断是否包含新值,都不行。
Dim zjs As String = "40281,40430,40520,40685,40972,41284,41173,41284,41173,41407,41569,41698"
Dim zjss() As String = zjs.Split(",")
msgbox(zjss.Contains(4052))
msgbox(zjss.IndexOf(4052))
这2种都不行,若行的话,我感觉这样更简单些。
Dim zjs As String = "40281,40430,40520,40685,40972,41284,41173,41284,41173,41407,41569,41698"
Dim zjss() As String = zjs.Split(",")
msgbox(zjss.Contains("4052"))