473,387 Members | 1,481 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,387 software developers and data experts.

How to do function that Left(String,int) in vb6?

mhw
I don't found function!
ThanksŁĄ
Nov 17 '05 #1
4 2722

mhw wrote:
I don't found function!
ThanksŁĄ


Try substring.

string s = "Hello world";
string left5 = s.Substring( s.Length-5, 5 );
Console.WriteLine("S = {0}", left5 );

Output:

S = world

Matt

Nov 17 '05 #2
mhw
OK.

Thank you!
Nov 17 '05 #3
BUT ....
Subtstring will throw an exception if any of its arguments resolve to
indexes not within the string it is being applied to:

EXAMPLE
string s = "AB";
string left5 = s.Substring( s.Length-5, 5 ); <<<< throws exception
here
"Matt" <ma********@sprynet.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Try substring.

string s = "Hello world";
string left5 = s.Substring( s.Length-5, 5 );
Console.WriteLine("S = {0}", left5 );

Output:

S = world

Matt
Nov 17 '05 #4
BUT ....
Subtstring will throw an exception if any of its arguments resolve to
indexes not within the string it is being applied to:

EXAMPLE
string s = "AB";
string left5 = s.Substring( s.Length-5, 5 ); <<<< throws exception
here
"Matt" <ma********@sprynet.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Try substring.

string s = "Hello world";
string left5 = s.Substring( s.Length-5, 5 );
Console.WriteLine("S = {0}", left5 );

Output:

S = world

Matt
Nov 17 '05 #5

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

Similar topics

16
by: | last post by:
I saw this code in C++ but when tried to C causes an error: ------------- void function(int &a) { a = 5; } ------------- with this, passed in "function" the "a" pointer instead of "a" value, BUT...
3
by: Sam | last post by:
I want to divide character into 2 section. Example, 200412 divided into 2004 in A block and 12 in B block. Please advise how to use left(string, length) or right(string, length) for above...
1
by: Wally | last post by:
Is there in VB NET something like the old Vb6 STRING$() function? Thanks. VV
6
by: Maverick | last post by:
There's a function in Borland C conio.h window (int left, int top, int right, int bottom) how can i provide the same function in VB.Net
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...
3
by: OutdoorGuy | last post by:
Greetings, I have a "newbie" question. I was wondering if there is anything in C# that corresponds to VB's "Left" function? I simply want to retrieve the leftmost characters of a string and I...
6
by: kellygreer1 | last post by:
What is a good one line method for doing a "length safe" String.Substring? The VB classes offer up the old Left function so that string s = Microsoft.VisualBasic.Left("kelly",200) // s will =...
3
by: AWW | last post by:
RichTextBox.Text = string & vbCR works but if I extract a substring with microsoft.visualbasic.left then vbCR stops working. I can do F5 executes with/without the Left and the vbCr does/doesNot...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.