Solved

How to use indexof property in C#

Posted on 2007-11-16
6
6,901 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help on C# Linq query on object 6 53
Not showing page correctly 3 31
Error in JQuery 5 39
free scanner TWAIN can be operated with a Web application 9 41
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 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

24 Experts available now in Live!

Get 1:1 Help Now