469,270 Members | 1,117 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

substring, left, right function ?

in .net , any left function ??
or I should use Microsoft.VisualBasic.Left(myString, 5)
Thanks
Nov 21 '05 #1
4 44042
Dim a As String = "ABCDEF"

Debug.WriteLine(a.Substring(0, 5))

'Returns ABCDE
--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uH**************@TK2MSFTNGP12.phx.gbl...
in .net , any left function ??
or I should use Microsoft.VisualBasic.Left(myString, 5)
Thanks

Nov 21 '05 #2
* "Agnes" <ag***@dynamictech.com.hk> scripsit:
in .net , any left function ??
or I should use Microsoft.VisualBasic.Left(myString, 5)


I suggest to use VB.NET's 'Left' function because it is more descriptive
than the string's 'Substring' method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Agnes,
The Left function in .NET is Microsoft.VisualBasic.Strings.Left!

If you use Strings.Left you may want to use an Import alias on
Microsoft.VisualBasic.

Imports VB = Microsoft.VisualBasic

Dim myString As String
myString = VB.Left(myString, 5)

Especially in Window Forms, as Left is a property of Control.

An alternative to Microsoft.VisualBasic.Strings is the methods on String
itself (such as String.SubString). I normally use String.SubString instead
of Strings.Left, however both are equally valid.

The one caveat I recommend is do not mix the VB Strings functions with the
String methods, as VB Strings are 1 based indexes & the String methods are 0
based indexes.

Hope this helps
Jay

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uH**************@TK2MSFTNGP12.phx.gbl...
in .net , any left function ??
or I should use Microsoft.VisualBasic.Left(myString, 5)
Thanks

Nov 21 '05 #4
I understand now, I will use substring instead.
Thanks ALL

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> bl
news:%2****************@TK2MSFTNGP14.phx.gbl g...
Agnes,
The Left function in .NET is Microsoft.VisualBasic.Strings.Left!

If you use Strings.Left you may want to use an Import alias on
Microsoft.VisualBasic.

Imports VB = Microsoft.VisualBasic

Dim myString As String
myString = VB.Left(myString, 5)

Especially in Window Forms, as Left is a property of Control.

An alternative to Microsoft.VisualBasic.Strings is the methods on String
itself (such as String.SubString). I normally use String.SubString instead of Strings.Left, however both are equally valid.

The one caveat I recommend is do not mix the VB Strings functions with the
String methods, as VB Strings are 1 based indexes & the String methods are 0 based indexes.

Hope this helps
Jay

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uH**************@TK2MSFTNGP12.phx.gbl...
in .net , any left function ??
or I should use Microsoft.VisualBasic.Left(myString, 5)
Thanks


Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by becte | last post: by
3 posts views Thread by vaughn | last post: by
3 posts views Thread by Tim Soliday | last post: by
15 posts views Thread by Duncan Allen | last post: by
2 posts views Thread by aidy | last post: by
11 posts views Thread by fniles | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.