Advertisement
ClarusDignus

Parenting >8 statement and >0 statement

Oct 25th, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'How to check if text box max length has been exceeded?
  2. 'http://stackoverflow.com/questions/26534314/how-to-check-if-text-box-max-length-has-been-exceeded
  3.  
  4. 'Parenting >8 statement and >0 statement with If ToolTip1.GetToolTip()
  5.  
  6. Public Class Form1
  7.     Private Sub Textbox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
  8.         If Not IsNumeric(TextBox1.Text) Then
  9.             If TextBox1.Text.Length > 8 Then
  10.                 If ToolTip1.GetToolTip(TextBox1) = "" Then
  11.                     TextBox1.Text = TextBox1.Text.Substring(0, 8)
  12.                     TextBox1.Select(TextBox1.TextLength, 0)
  13.                     ToolTip1.IsBalloon = True
  14.                     ToolTip1.ToolTipTitle = "8 character maximum and input must be numeric!"
  15.                     ToolTip1.Active = True
  16.                     ToolTip1.ToolTipIcon = ToolTipIcon.Warning
  17.                     ToolTip1.Show(vbNewLine, TextBox1, 45, -40, 2000)
  18.                 End If
  19.             ElseIf TextBox1.Text.Length > 0 Then
  20.                 If TextBox1.Text.Length > 8 Then
  21.                     ToolTip1.ToolTipTitle = "Input must be numeric!"
  22.                     ToolTip1.Active = True
  23.                     ToolTip1.IsBalloon = True
  24.                     ToolTip1.ToolTipIcon = ToolTipIcon.Warning
  25.                     ToolTip1.Show(vbNewLine, TextBox1, 45, -40, 2000)
  26.                 End If
  27.             End If
  28.         Else
  29.             If TextBox1.Text.Length > 8 Then
  30.                 TextBox1.Text = TextBox1.Text.Substring(0, 8)
  31.                 TextBox1.Select(TextBox1.TextLength, 0)
  32.                 ToolTip1.IsBalloon = True
  33.                 ToolTip1.ToolTipTitle = "8 character maximum!"
  34.                 ToolTip1.Active = True
  35.                 ToolTip1.ToolTipIcon = ToolTipIcon.Warning
  36.                 ToolTip1.Show(vbNewLine, TextBox1, 45, -40, 2000)
  37.             Else
  38.                 ToolTip1.Active = False
  39.                 ToolTip1.Hide(TextBox1)
  40.             End If
  41.         End If
  42.     End Sub
  43. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement