0

I was just wondering if there is a possible way to get the last 4 characters from a label or textbox. If someone could please provide me with an example that would be great!

Thanks..

4
Contributors
7
Replies
25
Views
4 Years
Discussion Span
Last Post by ddanbe
0

use like this :

 Dim str As String
        str = TextBox1.Text.Substring(Math.Max(0, TextBox1.Text.Length - 4))
        MsgBox(str)
0
use like this :

 Dim str As String
        str = TextBox1.Text.Substring(Math.Max(0, TextBox1.Text.Length - 4))
        MsgBox(str)

That seems to work. Thanks guys... :D

0

Yeah, this also works:

str.Substring((Math.Max(0, (str.Length - 4) * Convert.ToInt32( Math.Sin( 4.0 * Math.Atan(1.0) / 2)))))

What is wrong with:

str.Substring(str.Length - 4)

This also does the job.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.