473,785 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

left(string, length) or right(string, length)?

Sam
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 request.

Many thanks in advance.
Nov 19 '05 #1
3 6100
Sam,
These questions are always hard to answer because we aren't 100% clear on how you want to split it. Will it always be the first 4 characters in the first block? Or will it always be the last 2 in the 2nd block? Or are they the same because the block will always be 6 characters?

Anyways, assuming it'll always be XXXXYY then I'd do:

Dim originalString As String = "200412"
Dim aBlock As String = originalString. Substring(0, 4)
Dim bBlock As String = originalString. Substring(4)

I prefer subString over left and right because it's more .net frameworkish (that is it'll work in C# as well)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sam" <cy********@hot mail.com> wrote in message news:Os******** ******@TK2MSFTN GP14.phx.gbl...
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 request.

Many thanks in advance.
Nov 19 '05 #2
Sam
It's mean aBlock is 2004 and bBlock is 12?

Yes, I want it split off, 2004 and 12 of 200412.

Do I need to declare something before originalString. Substring? Explicit Options?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:e%******** ********@TK2MSF TNGP09.phx.gbl. ..
Sam,
These questions are always hard to answer because we aren't 100% clear on how you want to split it. Will it always be the first 4 characters in the first block? Or will it always be the last 2 in the 2nd block? Or are they the same because the block will always be 6 characters?

Anyways, assuming it'll always be XXXXYY then I'd do:

Dim originalString As String = "200412"
Dim aBlock As String = originalString. Substring(0, 4)
Dim bBlock As String = originalString. Substring(4)

I prefer subString over left and right because it's more .net frameworkish (that is it'll work in C# as well)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sam" <cy********@hot mail.com> wrote in message news:Os******** ******@TK2MSFTN GP14.phx.gbl...
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 request.

Many thanks in advance.
Nov 19 '05 #3
Sam:
Everything in the code I gave you is explicitely declared....I'm making use of three variables "originalString " , "aBlock" and "bBlock" Option Explicit is automatically turned on in VB.Net

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sam" <cy********@hot mail.com> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
It's mean aBlock is 2004 and bBlock is 12?

Yes, I want it split off, 2004 and 12 of 200412.

Do I need to declare something before originalString. Substring? Explicit Options?

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:e%******** ********@TK2MSF TNGP09.phx.gbl. ..
Sam,
These questions are always hard to answer because we aren't 100% clear on how you want to split it. Will it always be the first 4 characters in the first block? Or will it always be the last 2 in the 2nd block? Or are they the same because the block will always be 6 characters?

Anyways, assuming it'll always be XXXXYY then I'd do:

Dim originalString As String = "200412"
Dim aBlock As String = originalString. Substring(0, 4)
Dim bBlock As String = originalString. Substring(4)

I prefer subString over left and right because it's more .net frameworkish (that is it'll work in C# as well)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Sam" <cy********@hot mail.com> wrote in message news:Os******** ******@TK2MSFTN GP14.phx.gbl...
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 request.

Many thanks in advance.
Nov 19 '05 #4

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

Similar topics

4
2738
by: mhw | last post by:
I don't found function! Thanks£¡
18
1760
by: Jm | last post by:
Hi all I feel stupid for asking this, but i just went to use the left() function from vb6 only to find it doesnt do what it used to under .NET. Im assuming theres something else now im meant to do when i want to say for example Dim Str as string Str = "1234" msgbox left(str,2)
3
15200
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 first part of the split. It works, but is really cumbersome and doesn't account for a string with two consecutive values that are the same, but I might want to include both of them Example: ('neccesarry') Result: 'necce'
3
75412
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 wasn't sure what the best way was to do that. Thanks in advance!
8
1433
by: Bas Nedermeijer | last post by:
Hello, what is a efficient solution to compare a string against a lot of possiblities? Currently i am having a lot of if (strcmp(checkme, "option1", strlen(checkme))) { value = OPTION1; }
6
9271
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
4010
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 work. Comment?
5
3772
by: =?Utf-8?B?Qm9iQWNoZ2lsbA==?= | last post by:
I need a function (or code) that will physically change the words in a text string to make the first word be last, second word next to last, etc. but maintain the same position of the letters in each word. e.g. Before: The dog ran After: ran dog the Is there such a thing?
2
1916
by: ventos | last post by:
First of all, ive been trying to learn c++ for a couple of days ;) Problem i need to strip http links from string code: string replaceAll(string s, string f, string r) { unsigned int found = s.find(f); while(found != string::npos) { s.replace(found, f.length(), r);
0
9646
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
9483
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
10157
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
10096
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
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
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
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.