tags:

views:

55

answers:

2
 dim dataType as String
  toolTip="Marks And Number[String]"

I want to get the [String] alone.

  dataType = toolTipText.Substring(toolTipText.IndexOf("[") + 1, toolTipText.IndexOf("]") - 1)

it shows an error. Regarding the length of the string.

What's wrong with my code.I dont know , Some times I have these type of problems . Standing with simple loops or conditions .

+4  A: 

The second parameter is length, not ending index. You need to subtract your starting index from it.

David M
+2  A: 

Not that it's great code but

dataType = toolTip.Substring(toolTip.IndexOf("[") + 1, toolTip.Length - toolTip.IndexOf("[") - 2)

would sort you out.

The second parameter is the length of the substring - not the end index.

Might be better to take a look at regex.

PaulB