|
Hello,
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Ideally, I would like to do something like Sql --If txt1.text In ("X", "Y",
"Z") then...
txt1.Text.Contains only deals with one string at a time so I would be back
to square one:
If txt1.text.contains("X") or txt1.text.contains("Y")...
What is the most efficient way to perform a check like this?
Thanks,
Rich | |
Share:
|
On Feb 1, 12:58 pm, Rich <R...@discussions.microsoft.comwrote:
Hello,
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Ideally, I would like to do something like Sql --If txt1.text In ("X", "Y",
"Z") then...
txt1.Text.Contains only deals with one string at a time so I would be back
to square one:
If txt1.text.contains("X") or txt1.text.contains("Y")...
What is the most efficient way to perform a check like this?
Thanks,
Rich
Regex?
Thanks,
Seth Rowe | | |
How about Instr("_X_Y_Z_")?
T
Rich wrote:
Hello,
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Ideally, I would like to do something like Sql --If txt1.text In ("X", "Y",
"Z") then...
txt1.Text.Contains only deals with one string at a time so I would be back
to square one:
If txt1.text.contains("X") or txt1.text.contains("Y")...
What is the most efficient way to perform a check like this?
Thanks,
Rich | | |
Thanks all for your replies. Regex and Instr should do the trick.
"Rich" wrote:
Hello,
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Ideally, I would like to do something like Sql --If txt1.text In ("X", "Y",
"Z") then...
txt1.Text.Contains only deals with one string at a time so I would be back
to square one:
If txt1.text.contains("X") or txt1.text.contains("Y")...
What is the most efficient way to perform a check like this?
Thanks,
Rich
| | |
what about something like ...
Select Case TextBox1.Text
Case "X", "Y", "Z"
MsgBox("XYZ")
Case "A", "B", "C"
MsgBox("ABC")
Case Else
MsgBox("None of the options were entered")
End Select
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:ED**********************************@microsof t.com...
Hello,
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Ideally, I would like to do something like Sql --If txt1.text In ("X",
"Y",
"Z") then...
txt1.Text.Contains only deals with one string at a time so I would be back
to square one:
If txt1.text.contains("X") or txt1.text.contains("Y")...
What is the most efficient way to perform a check like this?
Thanks,
Rich
| | |
Rich wrote:
Hello,
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Ideally, I would like to do something like Sql --If txt1.text In ("X", "Y",
"Z") then...
txt1.Text.Contains only deals with one string at a time so I would be back
to square one:
If txt1.text.contains("X") or txt1.text.contains("Y")...
What is the most efficient way to perform a check like this?
Thanks,
Rich
The IndexOf method of the string class looks for a string inside
another. It's like the InStr function, but for .NET.
If "XYZ".IndexOf(txt1.Text) <-1 Then
--
Göran Andersson
_____ http://www.guffa.com | | |
Rich wrote:
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Personally, as soon as I see a checks for something like
thing = X or Y or Z
I reach for the Select Case construct - it's just easier on the eye.
Select Case txt1.text
Case "X", "Y", "Z"
Case Else
End Select
Then how about :
If txt1.Text.IndexOfAny(New Char() {"X"c, "Y"c, "Z"c}) = 0 Then
' :-)
End If
HTH,
Phill W. | | |
Sorry I am behind the times but could use not use something like the
following for multiple checks?
If TextBox1.Text.IndexOfAny("X,Y,Z".ToCharArray) <-1 Then
"Rich" <Ri**@discussions.microsoft.comwrote in message
news:ED**********************************@microsof t.com...
Hello,
I need to check if a textbox (of size = 1) contains a specific value
(character). I could say something like
If txt1.text.equals("X") or txt1.text.equals("Y")... then...
Ideally, I would like to do something like Sql --If txt1.text In ("X",
"Y",
"Z") then...
txt1.Text.Contains only deals with one string at a time so I would be back
to square one:
If txt1.text.contains("X") or txt1.text.contains("Y")...
What is the most efficient way to perform a check like this?
Thanks,
Rich
| | This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by Robin Tucker |
last post: by
|
1 post
views
Thread by Paul Thakur |
last post: by
|
4 posts
views
Thread by Robert W. |
last post: by
|
2 posts
views
Thread by Daren Hawes |
last post: by
|
16 posts
views
Thread by mj.redfox.mj@gmail.com |
last post: by
| | | | | | | | | | | | | | | |