0
 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 .

2 Answers 2

4

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

Sign up to request clarification or add additional context in comments.

Comments

2

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.