954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Remove the first character of a string in a datagrid

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?

spinnaret
Newbie Poster
16 posts since Sep 2008
Reputation Points: 10
Solved Threads: 1
 

Use LEN to find the length of any string.

Use LTrim to remove the first character.

myString = LTrim(myString, 1)

jadamez
Newbie Poster
1 post since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

In the .NET way:

If datgridview.item(x,y).value.tostring.substring.Length > 0 Then
  datgridview.item(x,y).value = datgridview.item(x,y).value.tostring.substring(0, datgridview.item(x,y).value.tostring.Length - 1)
End If
Teme64
Veteran Poster
1,031 posts since Aug 2008
Reputation Points: 218
Solved Threads: 203
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You