473,700 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

substring, left, right function ?

in .net , any left function ??
or I should use Microsoft.Visua lBasic.Left(myS tring, 5)
Thanks
Nov 21 '05 #1
4 44330
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***@dynamict ech.com.hk> wrote in message
news:uH******** ******@TK2MSFTN GP12.phx.gbl...
in .net , any left function ??
or I should use Microsoft.Visua lBasic.Left(myS tring, 5)
Thanks

Nov 21 '05 #2
* "Agnes" <ag***@dynamict ech.com.hk> scripsit:
in .net , any left function ??
or I should use Microsoft.Visua lBasic.Left(myS tring, 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.Visua lBasic.Strings. Left!

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

Imports VB = Microsoft.Visua lBasic

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

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

An alternative to Microsoft.Visua lBasic.Strings is the methods on String
itself (such as String.SubStrin g). I normally use String.SubStrin g 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***@dynamict ech.com.hk> wrote in message
news:uH******** ******@TK2MSFTN GP12.phx.gbl...
in .net , any left function ??
or I should use Microsoft.Visua lBasic.Left(myS tring, 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******** ********@TK2MSF TNGP14.phx.gbl ¤¤¼¶¼g...
Agnes,
The Left function in .NET is Microsoft.Visua lBasic.Strings. Left!

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

Imports VB = Microsoft.Visua lBasic

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

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

An alternative to Microsoft.Visua lBasic.Strings is the methods on String
itself (such as String.SubStrin g). I normally use String.SubStrin g 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***@dynamict ech.com.hk> wrote in message
news:uH******** ******@TK2MSFTN GP12.phx.gbl...
in .net , any left function ??
or I should use Microsoft.Visua lBasic.Left(myS tring, 5)
Thanks


Nov 21 '05 #5

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

Similar topics

6
22744
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? // Remove (first occurence of) sub from src void func(char *src, char *sub) { char *p;
3
19215
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 substring's usually in the middle. Thanks.
3
10306
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 any information that I might want whether it is to the left or right of that substring. For example: //Position of substring has already been determined
15
6074
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: string creationDateStr = string.Empty; string anotherStr = "";
2
1400
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 using the function 'substring-after'
11
2217
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. For ex: sStr = "a", if I do sStr.Substring(0, 3), it will give me an error. So, I was forced to do
6
9267
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 = "kelly" with no error // but string s2 = "kelly".Substring(0,200) // results in // ArgumentOutOfRangeException
3
5152
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 embedded in other text. Here's my sql: use fto_ups select distinct o.Shipper#, o.InvoiceDate, o.InvoiceNumber, o.ChgType, o.Lading, o.BillTo, o.Name2, o.Address1, o.Address2, o.City, o.State, o.Zip, o.ShipFromName1, o.ShipFromeName2,...
1
2055
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 periodend from it. The periodstart will always be the third substring from the end (or 3rd from right) and the periodend will always be the first substring from the end (or 1st from the right). How can I extract the periodstart and periodend? ...
0
8721
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9209
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9069
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8964
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8918
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4653
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3085
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.