正确使用星号

dwb*_*dwb 2 vb.net

对我来说是愚蠢的问题.我曾多次使用'*',但对于我的生活,我不记得如何.

示例:ComboBox1中的文本是iPad安装指南2015我想在代码中保持通用(所以如果它更改为2016)

我有以下代码:

If ComboBox1.Text = "iPad Setup Guide" Then
Run Code Online (Sandbox Code Playgroud)

我试过的代码:

If ComboBox1.Text = "iPad Setup Guide*" Then
If ComboBox1.Text = "iPad Setup Guide" + "*" Then
Run Code Online (Sandbox Code Playgroud)

我忘记了什么?

谢谢,

Ste*_*art 5

我相信你正在考虑VB.NET的Like运算符:

If ComboBox1.Text Like "iPad Setup Guide*" Then
    ' ...
End If
Run Code Online (Sandbox Code Playgroud)

但是,对于更强大的模式匹配,您可能还需要考虑使用RegEx:

If RegEx.IsMatch(ComboBox1.Text, "Pad Setup Guide.") Then
    ' ...
End If 
Run Code Online (Sandbox Code Playgroud)