搜索表带有x个参数 [英] Search table with x number of arguments
问题描述
我正在尝试查找所需的表行索引.困难之处在于,我需要检查在列中找到的多个值.
I'm trying to find a desired row index of a table(s). Difficulty is that I need to check multiple values found in the columns.
例如.
- 表1有1个唯一列
- 表2有2列找到唯一行
- 表3有3列找到唯一行
如果希望我的函数搜索给定参数的列数.但是我不太清楚.
If would like my function to search the number of given arguments for the columns. But I don't quite know how.
我当时正在考虑传递一个数组{"Value1","Value2","Value3"}
I was thinking of passing a array{"Value1", "Value2", "Value3"}
但是如何根据行数检查行是否匹配?
But how can I check based on the number of arguments if the row matches?
我当时在想这样的事情,但是也许有更好的解决方案来解决这个问题?
I was thinking somthing like this, but maybe there is a better solution to this problem?
Private Function FindRow(ByVal StringArray As String())
Dim NumberOfArguments As Integer = oStringArray.Length
Dim MatchesCount As Integer = 0
For i = 0 as integer to rows.count
For x = 0 as integer to columns.count
对于y = 0作为NumberOfArguments的整数 如果Row(i).Column(x).value = StringArray(y)然后 MatchesCount + = 1 如果结束
For y = 0 as integer to NumberOfArguments If Row(i).Column(x).value = StringArray(y) Then MatchesCount += 1 End If
下一步 下一个 如果MatchesCount = NumberOfArguments,则 FindRow =我 万一 下一个 结束功能
Next Next If MatchesCount = NumberOfArguments Then FindRow = i End If Next End Function
推荐答案
你好,
我建议您使用 查找方法(页面上有一个简单的示例),该方法可以使用主键.开始让逻辑以非通用的方式工作(您当前的方法是通用的),然后一旦可行,您就可以决定是否仍然需要通用的方法,而该方法最终将继续使用 成为更多代码.
I would suggest working with the Find method (page has a simple example) which works off primary keys. Start off getting the logic to work in a non-generic way (your current method is generic) then once that works you can decide if you still want a generic method which in the end is going to be more code.
这篇关于搜索表带有x个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!