I need to insert an "If/Then" statement that will require the command to check the string for multiple variables. In other words it needs to say something like this:

If Microsoft.VisualBasic.Mid(txtLine, 18, 1) = "C" or "T" or "G" or "W" Then
    Go do something
End If

After doing some reading, it seems that "Regex" may be the way to correctly write this. However this is a new command to me and I'm not sure how to write something like this. Can you give me a hand?

In advance, thanks for the help.


2 Years
Discussion Span
Last Post by Reverend Jim

Minimalist, You're probably on the right track for me. However I'm not sure I understand "Select Case" even after reading as I'm not sure how to incorporate this in my If/Then statement. This is because my statement is going to be somewhat complex.

I think I will mark this solved and resubmit the question as "If/Then and Select Case".


There is an addin tool available for versions of Visual Studio up to 2012 that will allow you to easily test your regular expressions. You can find it here

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.