473,385 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

C# equivalent of VB6 Left

What is the C# equivalent of Left in VB6? I'm not sure how to translate
this line of code :

strResultCode = Left$(txtOutput, InStr(1, txtOutput, ",") - 1)
Any help would be really appreciated.
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
4 6171
Use:
string.Substring(start, length);

ie:
string something = "this is,my text";
string newString = something.Substring(0, something.IndexOf(","));

"Mike P" <mr*@telcoelectronics.co.uk> wrote in message
news:Oo**************@TK2MSFTNGP11.phx.gbl...
What is the C# equivalent of Left in VB6? I'm not sure how to translate
this line of code :

strResultCode = Left$(txtOutput, InStr(1, txtOutput, ",") - 1)
Any help would be really appreciated.
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2
I presume you're looking to take all the string characters to the left of
the ","?
SubString does quite well here...

int CommaIndex = Output.IndexOf ( ',' );
if ( CommaIndex >= 0 )
{
// comma found
ResultString = Output.SubString ( 0, CommaIndex );
}
else
{
// for a case with no ,
ResultString = Output; // or ""?
}

"Mike P" <mr*@telcoelectronics.co.uk> wrote in message
news:Oo**************@TK2MSFTNGP11.phx.gbl...
What is the C# equivalent of Left in VB6? I'm not sure how to translate
this line of code :

strResultCode = Left$(txtOutput, InStr(1, txtOutput, ",") - 1)
Any help would be really appreciated.
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #3
strResultCode = txtOutput.Substring(0, txtOutput.IndexOf(",", 0));

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #4
Thanks Ben, Dan!
Cheers,

Mike

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
1
by: JBBHF | last post by:
Hi i'm working on a web project, and i would like to make my oracle query work in mysql. select match.numero "nummatch", to_char(match.datematch, 'yyyy-MM-dd') "datematch", p1.numjoueur "j1",...
27
by: junky_fellow | last post by:
Is *ptr++ equivalent to *(ptr++) ?
3
by: Tim Soliday | last post by:
I have been looking at regular expressions lately, and I'm hoping that maybe someone could help me? I am trying to find the position of a substring, and then returning the substring including...
3
by: NathanC | last post by:
Left('ironman',4) Result - 'iron' Is there anyway to excute this task in VB.NET? Currently, I am determing the value of the 4th character, splitting on that, then grabbing the value of the...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
2
by: Tasman | last post by:
Is there an equivalent of valign="bottom" for a table within a DIV using CSS? I've found I can center a table of buttons in a DIV with {margin-left:auto; margin-right:auto}. But I am unsure how...
1
by: tlemcenvisit | last post by:
Hello, Please, what is the equivalent code of if(e.Button == MouseButtons.Left) in VC++.NET Thanks in advance
0
by: AJ | last post by:
Hi all, I have the following query which isn't quite finished! 1) How do i specify the '@Country' parameter is optional in an ACCESS stored query? (like MSSQL @Country INT = NULL) 2) What is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.