title: Max length for decimal tetbox
body: <p>I would like to create a TextBox that allows users to key in decimal values. Now the catch is, I want to give maxlength to the integral part(value before decimal) so when i say the maxlength is 5</p>
  
  <p>User can enter</p>
  
  <pre><code>.12
  12345
  12345.67
  </code></pre>
  
  <p>User should not be able to enter</p>
  
  <pre><code>123456
  123456.78
  </code></pre>
  
  <p>I am handling the textbox keypress to restrict the alphabets</p>
  
  <pre><code>If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) AndAlso e.KeyChar &lt;&gt; "."c Then
      e.Handled = True
  End If
  
  ' only allow one decimal point
  If e.KeyChar = "."c AndAlso TryCast(sender, TextBox).Text.IndexOf("."c) &gt; -1 Then
      e.Handled = True
  End If
  </code></pre>
  
  <p>Can somebody please help me with this maxlength part. Appreciate any help and directions.</p>