|
-
Jul 17th, 2006, 03:32 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Simple String Manipulation
I have values that change in string length.
Say 234547,54677,7899077....
I would like to use substring to get the last five digits from every value.
For example the above would give me 34547,54677,99077
How do i do it?
-
Jul 17th, 2006, 03:36 AM
#2
Re: Simple String Manipulation
Use String.Split to split the string at , and then loop through the resulting array to get last 5 characters of easch string.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jul 17th, 2006, 03:37 AM
#3
Fanatic Member
Re: Simple String Manipulation
use Split function and "," as the delimiter then
use loop and Right function.
-
Jul 17th, 2006, 03:39 AM
#4
Thread Starter
Hyperactive Member
Re: Simple String Manipulation
Sorry, i confused by including the comma there.
Each value is on its own.
-
Jul 17th, 2006, 03:41 AM
#5
Re: Simple String Manipulation
 Originally Posted by maps
Sorry, i confused by including the comma there.
Each value is on its own.
Then you can just use Substring to get the last 5 characters.
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jul 17th, 2006, 03:42 AM
#6
Thread Starter
Hyperactive Member
Re: Simple String Manipulation
My problem is that substring maniplulation starts from the left to the right and unless all values have the same length, i cant manipulate to get the last 5 digits.
A work around is what i am seeking.
-
Jul 17th, 2006, 03:45 AM
#7
Re: Simple String Manipulation
How about using this
VB Code:
string sTemp = "7899077";
MessageBox.Show(sTemp.Substring(sTemp.Length - 5,5));
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jul 17th, 2006, 03:51 AM
#8
Fanatic Member
Re: Simple String Manipulation
How about this:
VB Code:
Dim myString As String = "234547,54677,7899077,345"
Dim Ctr As Integer
For Ctr = 0 To Strings.Split(myString, ",", , CompareMethod.Text).Length - 1
MsgBox(Strings.Right(Strings.Split(myString, ",", , CompareMethod.Text)(Ctr).ToString, 5))
Next
-
Jul 17th, 2006, 03:51 AM
#9
Thread Starter
Hyperactive Member
Re: Simple String Manipulation
I am sooo Dumb Today! Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|