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 7 19384
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 thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Robin Tucker |
last post by:
Hi,
I would like to select records from a table where the following criteria
hold:
SELECT * from Mytable where
field x "contains" string @X
or
|
by: Paul Thakur |
last post by:
I am writing vbscript code in an .asp page. I need to display field values
from a sql table consisting of several fields, one of them is of type "Long
Text". This field contains XML data. I like to...
|
by: Robert W. |
last post by:
I've built a complex collection object from
"System.Collections.CollectionBase". With regard to it, I have a question
about the "Contains" method.
At first I thought that "Contains" would...
|
by: Daren Hawes |
last post by:
Hi
I need to add an attribute to a Textbox to make it read only.
To add a CSS I use
DeptDate.Attributes("Class") = "textInput"
That adds 'Class="textinput"', but the readonly is like..
|
by: mj.redfox.mj |
last post by:
Can anyone help? I have a textbox which I'm programatically adding by
using the following code:
txtTest = New TextBox
txtTest.ID = "txtLeft" + cntCount.ToString...
|
by: aRTx |
last post by:
I want to send sms from my sajt, i have some code but i don't know enaught.
I have an account in one of sms service server ...
code:
<a href =...
|
by: brsawvel |
last post by:
Hello,
I have a form that has two subforms within it (frm1 - subfrm1, subfrm2)
Does anyone know how I can create an "On Click" event for a textbox -fld1- that is within -subfrm1-...
|
by: nev |
last post by:
my textbox displays "hello"
i change the value of textbox through code like this:
textbox.text = ""
then i do:
bindingsource.endedit()
tableadapter.update(dataset.datatable)
|
by: Meganutter |
last post by:
Hi,
is there some sort of setting or function where you can cut the text of a textbox with "..." like you sometimes see at the browse field of an installer?
example
...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |