473,407 Members | 2,326 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,407 software developers and data experts.

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 6070
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********@hotmail.com> wrote in message news:Os**************@TK2MSFTNGP14.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%****************@TK2MSFTNGP09.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********@hotmail.com> wrote in message news:Os**************@TK2MSFTNGP14.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********@hotmail.com> wrote in message news:%2****************@TK2MSFTNGP10.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%****************@TK2MSFTNGP09.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********@hotmail.com> wrote in message news:Os**************@TK2MSFTNGP14.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
by: mhw | last post by:
I don't found function! ThanksŁˇ
18
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...
3
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...
3
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...
8
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
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: 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...
5
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...
2
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.