Remove the first character of a string in a datagrid

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 16
Reputation: spinnaret is an unknown quantity at this point 
Solved Threads: 1
spinnaret spinnaret is offline Offline
Newbie Poster

Remove the first character of a string in a datagrid

 
0
  #1
Oct 13th, 2008
Hello I need to remove the first character of every string in a datagridview.

However when I try to use
datgridview.item(x,y).value.tostring.substring
I get an error because I do not know the lenghtb of the substring.

Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1
Reputation: jadamez is an unknown quantity at this point 
Solved Threads: 0
jadamez jadamez is offline Offline
Newbie Poster

Re: Remove the first character of a string in a datagrid

 
0
  #2
Oct 13th, 2008
Use LEN to find the length of any string.

Use LTrim to remove the first character.

myString = LTrim(myString, 1)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: Remove the first character of a string in a datagrid

 
0
  #3
Oct 13th, 2008
In the .NET way:
  1. If datgridview.item(x,y).value.tostring.substring.Length > 0 Then
  2. datgridview.item(x,y).value = datgridview.item(x,y).value.tostring.substring(0, datgridview.item(x,y).value.tostring.Length - 1)
  3. End If
Reply With Quote Quick reply to this message  
Reply

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



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC