Solved

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

Posted on 2011-03-02
6
720 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
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 400 total points
ID: 35019968
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 35019975
wham bam! that was simple.........
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 17

Assisted Solution

by:nepaluz
nepaluz earned 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now