Advertisement
ClarusDignus

Parenting >8 statement instead of >0 statement

Oct 25th, 2014
45
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 instead of >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.                 ToolTip1.ToolTipTitle = "Input must be numeric!"
  21.                 ToolTip1.Active = True
  22.                 ToolTip1.IsBalloon = True
  23.                 ToolTip1.ToolTipIcon = ToolTipIcon.Warning
  24.                 ToolTip1.Show(vbNewLine, TextBox1, 45, -40, 2000)
  25.             End If
  26.         Else
  27.             If TextBox1.Text.Length > 8 Then
  28.                 TextBox1.Text = TextBox1.Text.Substring(0, 8)
  29.                 TextBox1.Select(TextBox1.TextLength, 0)
  30.                 ToolTip1.IsBalloon = True
  31.                 ToolTip1.ToolTipTitle = "8 character maximum!"
  32.                 ToolTip1.Active = True
  33.                 ToolTip1.ToolTipIcon = ToolTipIcon.Warning
  34.                 ToolTip1.Show(vbNewLine, TextBox1, 45, -40, 2000)
  35.             Else
  36.                 ToolTip1.Active = False
  37.                 ToolTip1.Hide(TextBox1)
  38.             End If
  39.         End If
  40.     End Sub
  41. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement