下面这段代码复制到命令窗口,如果:
1、Find("[第二列] Like '%J%'") ,则可以正确运行。
2、替换成随机变量,Find("[第二列] Like '% & vs(Rand.Next(0,vs.Count-1)) & %'") ,或Find("[第二列] Like '% & v1 & %'"),
则不出结果。如何解决?
我的目的是这样的:
1、随机从中声母中选取一个声母。
2、从第二列中找到这个声母的行,以便引用本行相关数据。
Dim value() As String = {"Q","K","D","T","J","G","Y","F","S","Sh","R","L","N","B","P","W","M","Z","Zh","H","C","Ch","X"}
Dim v1 As String
Dim idx As Integer
Dim nList As new List(of String)
Dim vs As new List(of String)
vs.AddRange(Value)
idx = Rand.Next(0,vs.Count-1)
v1 = vs(idx)
msgbox(v1)
Dim dr As DataRow
'dr = DataTables("表A").Find("[第二列] Like '%J%'") '正确运行
'dr = DataTables("表A").Find("[第二列] Like '% & vs(Rand.Next(0,vs.Count-1)) & %'") '不报错,但也得不到正确结果.
dr = DataTables("表A").Find("[第二列] Like '% & v1 & %'") '不报错,但也得不到正确结果.
If dr IsNot Nothing Then
Dim wz As Integer = Tables("表A").FindRow(dr)
If wz >= 0 Then
Tables("表A").Position = wz
dr("第四列") = 999
End If
End If