473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

string compare

how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"
Nov 16 '05 #1
5 1257

"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"


Have a look at the IndexOf() method in the String class.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #2

"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"


Have a look at the IndexOf() method in the String class.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #3
try
if(Text1.IndexOf("nah") != -1)
{
....
}

--
-Philip Rieck
http://philiprieck.com/blog/

-
"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"

Nov 16 '05 #4
try
if(Text1.IndexOf("nah") != -1)
{
....
}

--
-Philip Rieck
http://philiprieck.com/blog/

-
"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"

Nov 16 '05 #5
Hi,

You can use IndexOf or LastIndexOf from String class

If it's a more complex expression you can use a regular expression, take a
look at Regex class and IsMatch method
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Dino L." <se******@gmail.com> wrote in message
news:uW**************@tk2msftngp13.phx.gbl...
how can I know does some string contain some chars?

Now I use
Text1.StartsWith("nah")

I need something like SQL code "text1 like('%nah%')"

Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: usgog | last post by:
I need to implement a function to return True/false whether String A contains String B. For example, String A = "This is a test"; String B = "is is". So it will return TRUE if String A includes two...
32
by: Wolfgang Draxinger | last post by:
I understand that it is perfectly possible to store UTF-8 strings in a std::string, however doing so can cause some implicaions. E.g. you can't count the amount of characters by length() | size()....
19
by: David zhu | last post by:
I've got different result when comparing two strings using "==" and string.Compare(). The two strings seems to have same value "1202002" in the quick watch, and both have the same length 7 which I...
6
by: Maileen | last post by:
Hi, I have the following code : Function GetRequestType(ByVal EvDt As String, ByVal StPeriod As String, ByVal EdPeriod As String, ByVal TaskType As String) As Integer Dim strtest As String Dim...
10
by: lchian | last post by:
Hi, For two stl strings s1 and s2, I got different results from strcmp(s1.c_str(), s2.c_str()) and s1.compare(s2) can someone explain what these functions do? It seems that strcmp gives...
14
by: Mosfet | last post by:
Hi, what is the most efficient way of doing a case insensitive comparison ? I am trying to write a universal String class and I am stuck with the case insensitive part : TCHAR is a char in...
11
by: Tony | last post by:
Hello! Below I have two different ways to test if the instance tb.Text contains the string "Programmer" So which one to use is it just a matter of taste ? Or could it be some advantage to one...
11
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
1
by: blunt | last post by:
trying to write a program to write the configuration files for a load of wireless access points. i've never been a good programmer and haven't done any for nearly a decade so have obviously made some...
5
by: erictheone | last post by:
so here is my code. My getlines for the strings keyword and phrase at lines 44 and 79 respectively don't work. Please help!!! #include <cstdlib> #include <string> #include <iostream> #include...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.