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?

Recommended Answers

All 2 Replies

Use LEN to find the length of any string.

Use LTrim to remove the first character.

myString = LTrim(myString, 1)

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.