473,387 Members | 1,548 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.

substring, left, right function ?

in .net , any left function ??
or I should use Microsoft.VisualBasic.Left(myString, 5)
Thanks
Nov 21 '05 #1
4 44317
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> ¦b¶l¥ó
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
3
by: vaughn | last post by:
Is there a function that'll let me find a substring of a fixed size? in other words, I'd like to get a substring in position X and length Y from a string. Left or Right wouldn't work since the...
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...
15
by: Duncan Allen | last post by:
Hi, Using C# I'm trying to use the substring method of a string variable but it just generates an "error: 'variable.Substring' does not exist " exception - how do I fix this ? code example: ...
2
by: aidy | last post by:
Hi, I am using XPath and XSLT and I have a string containing something like this: "gbahes75\Projects\AddressService\Datapool\EnterAddress.sdd" I want to get'EnterAddress.sdd', and I am...
11
by: fniles | last post by:
In VB 6 I used to do like the following: if left(str,3) = "abc" then In VB.NET when I do the following sStr.Substring(0, 3), and the sStr has fewer than 3 characters, it will give me an error....
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: Rnt6872 | last post by:
Hello All, I have a sql statement that I'm using to match records on. But i need to use a substring to get the nuber that I need, and I have to use several substrings to get the number since its...
1
by: sjharri | last post by:
I have an application providing me with multiple headers which I have mergerd into one big header (below), this header my not always be the same but I need to be able to extract a periodstart and...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.