Solved

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

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

Expert Comment

by:nepaluz
ID: 35019975
wham bam! that was simple.........
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

635 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