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..
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..
Jump to PostUse SubString method. Click Here
Jump to PostThe answer is Substring
Use this code:
Dim str As String = "abcd1234"
MsgBox(str.Substring(Math.Max(0, str.Length - 4)))
The answer is Substring
@ khair.ullah: What about str.Substring(str.Length - 4) ?
use like this :
Dim str As String
str = TextBox1.Text.Substring(Math.Max(0, TextBox1.Text.Length - 4))
MsgBox(str)
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
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.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.