In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "VB.NET how to use text boxes", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "VB.NET how to use text boxes" this article.
VB.NET text box 1, set read-only text box
Sometimes a piece of information is displayed in the window, but you don't want the user to change it. How to make the text read-only? First of all, we can use the read-only attribute of the label box (label) to replace the text box with tags to achieve the read-only attribute, but we can also use Mini Program to achieve the real text box read-only.
Sub Text1_KeyPress
(keyascii As Integer)
Keyascii = 0
End Sub
Alternatively, you can use the sendkey method to make the text box lose focus, such as the following program:
Sub Text1_KeyDown
(KeyCode As Integer
Shift As Integer)
SendKeys "{tab}"
End Sub
Or set the properties of the control directly, as follows:
Set Text1.Enabled=True so that Text1 cannot get focus after setting it
Set Text1.Locked=True so that Text1 can get focus after setting it
VB.NET text box 2, the input content and format of the qualified text box
The following program allows you to restrict text boxes to entering only numbers:
Private Sub Text1_KeyPress
(KeyAscii As Integer)
If KeyAscii
< Asc(0) Or KeyAscii >Asc (9) Then
KeyAscii = 0
MsgBox "Please enter a number"
End If
End Sub
If you want to limit the input format of the text box, you can use the FORMAT function of VB or the professional version of the masking control (Masked Edit). You can precisely control the input format of the text box by setting the Mask property of the masking control.
VB.NET file name sorting is easy to master
Detailed explanation of practical skills of VB.NET List
The function of VB.NET pointer in practical application
Advantages and result description of VB.NET Crystal report
Easily create VB.NET file merge examples
VB.NET text box 3. Create shortcut keys for TextBox
VB stipulates that the controls added to the form record their loading order in their Tabindex property, and the program runtime focus jumps between controls in the order specified by the Tabindex property. To simplify the operation, a shortcut key can be created in VB for any control that has a caption attribute, which is achieved by prefixing the letter you want to use as a shortcut key with a & sign in the caption attribute. One problem worth noting, however, is that controls such as text boxes do not have properties such as caption, so you can use labels with text boxes at the same time. To create a shortcut key for lable, the label Tabindex property setting is 1 smaller than the text box, and because label cannot receive clicks, the focus automatically jumps to the text box. This is equivalent to creating a shortcut key for the text box. The specific steps are as follows:
(1) draw the label first, then draw the text box. Or draw all kinds of controls at will, and set the label Tabindex attribute to be smaller than the text box by 1.
(2) use the "&" sign in the caption attribute of the tag to set the shortcut key. This is equivalent to setting a shortcut for the text box, and when you press the shortcut key for the label box, the focus jumps to the text box.
VB.NET text box 4. Wrap the text box at design time
For text boxes, you cannot enter line breaks in the design properties window, but you can wrap them with code when the program is executed, even with 13 and 10 of the ASCII characters, such as the following Mini Program, you can put two lines of text into the text box:
Sub form_load ()
NL=chr (13) + chr (10)
Text1.text= "my name
Is "& NL &" liu qiang "
End sub
VB.NET text box 5. Create password text box
The password text box can be created by setting properties or by calling the API API of WINDOWS. First, the text box properties Passwordchar and maxlength can be used to set the password box. Where Passwordchar specifies the characters displayed in the text box, if you specify "*", it displays "*" in the text box, and Maxlength determines how many characters can be entered in the text box. After the Maxlength is exceeded, the text box warns and cannot receive any more characters. If you use WINDOWS application function interface, you can use GetWindowLong, SetWindowsLong and SendMessage interface functions to achieve.
The above is all the content of the article "how to use text boxes in VB.NET". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.