How do I delete the last character of a string

Please support our VB.NET advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2007
Posts: 1
Reputation: shoebodh is an unknown quantity at this point 
Solved Threads: 0
shoebodh shoebodh is offline Offline
Newbie Poster

How do I delete the last character of a string

 
0
  #1
Jul 10th, 2007
I am a beginner in VB. I am trying to make a simple unit converter. Can please some body tell me how can I delete the last character of the number I enter in my inputbox?

thank you
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: How do I delete the last character of a string

 
0
  #2
Jul 11th, 2007
Take input as a string. Chop of the last character, then convert string to number.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: How do I delete the last character of a string

 
1
  #3
Jul 11th, 2007
I assume you are putting your input to a textbox. So try this:
  1. TextBox1.Text = InputBox("Enter number")
  2. TextBox1.Text = TextBox1.Text.Substring(0, TextBox1.Text.Length - 1)
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 65
Reputation: SolTec is an unknown quantity at this point 
Solved Threads: 4
SolTec SolTec is offline Offline
Junior Poster in Training

Re: How do I delete the last character of a string

 
0
  #4
Feb 21st, 2008
Originally Posted by shoebodh View Post
I am a beginner in VB. I am trying to make a simple unit converter. Can please some body tell me how can I delete the last character of the number I enter in my inputbox?

thank you
You also could use the IsNumeric(TextboxName.Text) Then
TextboxName.Text.Length -1 as the other poster stated which will subtract the last number in the textbox
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: How do I delete the last character of a string

 
0
  #5
Feb 21st, 2008
  1. Dim str As string
  2. str = "Ramy1"
  3. str = str.Remove(str.Length - 1);
  4. ' str = Ramy
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: How do I delete the last character of a string

 
0
  #6
Feb 21st, 2008
i think wayne already answered this thread.
Last edited by Jx_Man; Feb 21st, 2008 at 11:25 pm.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: How do I delete the last character of a string

 
0
  #7
Feb 22nd, 2008
Yes yes thanks JX
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 22501 | Replies: 6
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC