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
Solved

How to use indexof property in C#

Posted on 2007-11-16
6
6,904 Views
Last Modified: 2013-12-17
How do i translate this VB6 code to C#
test = InStr(1, strText, vbTab)

I tried

test  = strText.Tostring().Indexof('\t',0)  -- but did not work




0
Comment
Question by:pratikshahse
  • 3
  • 2
6 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20299984
assumming test is integer and strText is a string. This should work

test  = strText.Indexof("\t")+1

0
 

Author Comment

by:pratikshahse
ID: 20300143
actually this is what i have

object item = lstMfgColors.SelectedItems[I];

string o = item.ToString().Indexof("\t",0);
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20300214
IndexOf returns an integer with position, not a string, just like InStr. So should be something like:

ListViewItem item = lstMfgColors.SelectedItems[I];
int pos = item.Text.Indexof("\t",0)+1;
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20302000
Is that what you need?
Maybe some sourcecode around it would be more explanatory...
0
 
LVL 1

Expert Comment

by:mmq2006
ID: 20303868
Could you please explain what this code does exactly:

test = InStr(1, strText, vbTab)
0
 
LVL 1

Expert Comment

by:mmq2006
ID: 20303909
try this:
- Use a string variable type string:
string segment = str.Substring(index1,len);
where segment is a variable to store the substring,
str is the original string,
index1 is the zero-based starting position of the substring that you want to extract,
len is the number of characters you wish to extract.

This should resolve it.
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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