Get last character from textbox

checking and add character to a textbox

Page 1 of 1

2 Replies - 10281 Views - Last Post: 24 December 2008 - 12:13 AM Rate Topic: -----

#1 Stressine  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 18-December 08

Get last character from textbox

Post icon  Posted 22 December 2008 - 08:59 PM

Hi,

I want to read the last character entered in a textbox and if the last character is not "/" it will add one.
I searched the internet and even tried using "textBox.EndsWith()"but it didnt work, it only add 3 more "/" to the end of the string. :blink:

Need help!! :cry2:

Thanx for any assistance in advance :^:

My current code:

If txtMain.Text.EndsWith(".") Then
			txtMain.Text = txtMain.Text.Insert(txtMain.Text.Length - 1, 1)
		Else
			strMainPath = txtMain.Text
		End If


Is This A Good Question/Topic? 0
  • +

Replies To: Get last character from textbox

#2 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Get last character from textbox

Posted 22 December 2008 - 09:08 PM

I think you need something like this:

If Not TextBox1.Text.EndsWith("/") Then
	 TextBox1.Text = TextBox1.Text.Insert(TextBox1.Text.Length, "/")
End If



You can use the If...Not statement to verify the opposite of a statement.

This post has been edited by Core: 22 December 2008 - 09:09 PM

Was This Post Helpful? 0
  • +
  • -

#3 Stressine  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 10
  • Joined: 18-December 08

Re: Get last character from textbox

Posted 24 December 2008 - 12:13 AM

Thanks, you saved me
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1