Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串数组,"alpha", "beta"...我想测试另一个字符串string2以返回 1,如果string2= "alpha",如果等于 2"beta"等。
"alpha", "beta"...
string2
"alpha"
"beta"
如果它是使用 Excel 的 Excel,我可以这样做application.match,但这在 Word 中不存在。
application.match
最终目标是从字母名称中返回相应希腊字母的 unicode 值,所以如果有更好的方法,我愿意接受建议。也许我写的python太多了,列表似乎是一种简单的方法。
您需要遍历数组并针对搜索到的值测试每个值。
这里有一些伪代码可以帮助您入门。
Dim greek() As String Dim x As Integer Dim searchString As String Dim match As Integer For x = LBound(greek) To UBound(greek) If greek(x) = searchString Then match = x Exit For End If Next x