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?
Printable View
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?
Use String.Split to split the string at , and then loop through the resulting array to get last 5 characters of easch string.
use Split function and "," as the delimiter then
use loop and Right function.
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.Quote:
Originally Posted by maps
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.
How about using thisVB Code:
string sTemp = "7899077"; MessageBox.Show(sTemp.Substring(sTemp.Length - 5,5));
I am sooo Dumb Today! Thanks.
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