title: How to split string in group in vb.net
body: <p>i'm amol kadam,I want to know how to split string in two part.My string is in Time format (12:12).&amp; I want to seperate this in hour &amp; minute format.the datatype for all variables are string. for hour variable used strTimeHr &amp; for minute strTimeMin .I tried below code but their was a exception <strong>"Index and length must refer to a location within the string.
  Parameter name: length"</strong> </p>
  
  <pre><code>                If Not (objDS.Tables(0).Rows(0)("TimeOfAccident") Is Nothing Or objDS.Tables(0).Rows(0)("TimeOfAccident") Is System.DBNull.Value) Then
                      strTime = objDS.Tables(0).Rows(0)("TimeOfAccident") 'strTime taking value 12:12
                      index = strTime.IndexOf(":")                        'index taking value 2  
                      lastIndex = strTime.Length                          'Lastindex taking value 5   
  
                      strTimeHr = strTime.Substring(0, index)               'strTime taking value 12 correctly
       strTimeMin = strTime.Substring(index + 1, lastIndex)   'BUT HERE IS PROBLEM OCCURE strTimeMin Doesn't taking any value
                      Me.NumUpDwHr.Text = strTimeHr
                      Me.NumUpDwMin.Text = strTimeMin
                  End If
  </code></pre>