我的问题很愚蠢。我已经用过“*”很多次了,但我怎么也记不起是怎么用的。
示例: ComboBox1 中的文本是 iPad 设置指南 2015 我想在代码中保持它的通用性(所以如果它更改为 2016 年)
我有代码:
If ComboBox1.Text = "iPad Setup Guide" Then
我尝试过的代码:
If ComboBox1.Text = "iPad Setup Guide*" Then
If ComboBox1.Text = "iPad Setup Guide" + "*" Then
我忘记了什么?
谢谢
最佳答案
我相信您正在考虑VB.NET的Like
运算符:
If ComboBox1.Text Like "iPad Setup Guide*" Then
' ...
End If
但是,为了更强大的模式匹配,您可能还需要考虑使用 RegEx:
If RegEx.IsMatch(ComboBox1.Text, "Pad Setup Guide.") Then
' ...
End If
关于vb.net - 星号的正确使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31305849/