Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

replacement function for "Result = instr("DogCatRatBat", "Cat") " in c# and vb.net

Posted on 2011-03-02
6
Medium Priority
?
733 Views
Last Modified: 2012-05-11
Most omnipotent guru's,
New to c# and vb.net.  I need a very clear cut example of the VB replacement for lResult = instr("DogCatRatBat", "Cat") in c# and vb.net.   I've seen many vb.net/c3 semi-examples that feature looking for a single character and returning the ordinal position.  But I haven't found anything that simply returns the location of a simple multi-character substring within a string.  Can someone post a clear and complete example of what I need to have?

regards,

Ted
0
Comment
Question by:tcalbaz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 11

Expert Comment

by:jasonduan
ID: 35019959
lResult = "DogCatRatBat".IndexOf("Cat");

Note: the returned index is  0-based
0
 
LVL 10

Accepted Solution

by:
Jini Jose earned 1600 total points
ID: 35019968
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 35019975
wham bam! that was simple.........
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Assisted Solution

by:nepaluz
nepaluz earned 400 total points
ID: 35019984
variation for VB.net

Dim lResult = "DogCatRatBat".IndexOf("Cat")

(just remove the semicolon)
0
 
LVL 20

Expert Comment

by:informaniac
ID: 35020014
Evrything is simple once you know it. :D
0
 
LVL 1

Author Closing Comment

by:tcalbaz
ID: 35020671
gmailjini - That was a good solution:

Example:
String str = "hallo world"
int pos = str.IndexOf("wo",0)

* The result would then be 7

nepuluz - I give you partial credit since you answered with in 3 minutes of gmailjini and your solution is so intriquing.

Thank you both!!

regards,

Ted
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question