VB.Net Counterpart to RIGHT$ and LEFT$ vb6 functions???

  • Thread starter Thread starter Alan Mailer
  • Start date Start date
A

Alan Mailer

Could someone tell me what the VB.Net counterparts are to the commands
in VB6 which used to allow me to return only the rightmost or leftmost
parts of a string?

Thanks in advance.
 
For Left, a fairly direct use of the string SubString method will do.
e.g., Left(y, 2) becomes y.Substring(0, 2)
For Right, it's only slightly more complex.
e.g., Right(y, 2) becomes y.Substring(y.Length - 2)
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
C++ to C++/CLI
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: convert VB or C# to C++/CLI
 
Alan said:
Could someone tell me what the VB.Net counterparts are to the commands
in VB6 which used to allow me to return only the rightmost or leftmost
parts of a string?

If you use
Imports VB=Microsoft.VisualBasic

then you can use VB.Left() and VB.Right() on strings.

The VB=... makes VB an alias of Microsoft.VisualBasic so you don't have to
keep typing it.

If you use String.Substring from the .NET framework then you should check if
the string is not Nothing first, and that you aren't trying to get a
substring that is outside the ends of the string.

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top