The vb.net implements a TextBox control input that specifies the number of decimal method implementations.

Source: Internet
Author: User

Private Sub textbox1_keypress (ByVal sender as System.Object, ByVal e as System.Windows.Forms.KeyPressEventArgs) Handles t Extbox1. KeyPress
If E.keychar = Chr (8) then Exit Sub

If InStr (TextBox1. Text, ".") = 0 Then TextBox1. MaxLength = "Else TextBox1". MaxLength = 13
If Len (TextBox1. Text)-InStr (textbox1. Text, ".") = 5 and Len (textbox1. Text) <> 5 Then E.keychar = CHR (0)
If Len (TextBox1. Text) = 7 and InStr (TextBox1. Text, ".") = 0 Then
E.keychar = "."
Else
e.handled = False
End If
If E.keychar = Chr and InStr (textbox1. Text, ".") = 0 Then Exit Sub
If E.keychar < Chr (Or e.keychar > chr) then E.keychar = Chr (0)
End Sub

Implement textbox can only input x.y decimal, maximum 7 bits, y maximum 5 bits.

The vb.net implements a TextBox control input that specifies the number of decimal method implementations.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.