Program Requirements: design a running interface, as shown in. When you select an operation in the "Operation options" framework, the text box changes accordingly, at the same time, the relevant operation instructions are displayed on the labels in the "operation instructions" framework.
Start now:
1. Set the property value:
Private sub form_load ()
Option1.tooltiptext = "cursor at the beginning of the text"
Option2.tooltiptext = "cursor at the end of the text"
Option3.tooltiptext = "starting from the third line of the cursor"
Option4.tooltiptext = "select the third line"
Option5.tooltiptext = "select all texts"
End sub
Tooltiptext only plays the same role as a help or reminder, that is, it displays a piece of text when you move your mouse over the control.
When you click the option control, the label control displays relevant operation instructions, Code As follows (only one is listed, and others are similar ):
Private sub option#click () 'cursor at the beginning of the text
Label1.caption = "the cursor is selected at the beginning of the text"
Label1.tooltiptext = "the cursor is selected at the beginning of the text"
'The additional code needs to be written here. Leave it empty first.
End sub
2. AccordingProgram The selstart and sellength attributes of textbox can be used to control the insertion and selection behaviors of Textbox (these attributes can only be used at runtime ). First, to display multi-line text in the Textbox Control, set the multiline attribute to true.
Get the focus, that is, display the cursor in the text box Text1.setfocus
Then select the cursor position, Text1.selstart = 0 , Indicating that the cursor starts with the text box; Text1.selstart = Len (text1.text) , Indicating that the cursor is at the end of the text box.
So how to let the cursor jump to the third line? I have to know how many bytes a row can input. I have been searching for a long time and have no idea what functions or methods can be used to find the number of bytes that a row can input, so I used a stupid method to find it. The Code is as follows ( If you know any other methods, please let me know. Thank you! ):
Private sub option3_click ()
Dim X as integer
X = Len (text1.text)
Text1.text = x' I have obtained 57
End sub
Then modify the code as follows (comment out the unnecessary code ):
Private sub option3_click ()
'Dim X as integer
Label1.caption = "starting from the third row with the cursor selected"
Label1.tooltiptext = "Start of the cursor in the third row selected"
Text1.setfocus
'X = Len (text1.text)
'Text1. text = x
Text1.selstart = 57*2
End sub
After calculating the number of bytes that a row can input, the following steps are well performed. The Code is as follows:
Private sub option4_click ()
Label1.caption = "All characters in the third row selected"
Label1.tooltiptext = "All characters in the third row are selected"
Text1.setfocus
Text1.selstart = 57*2
Text1.sellength = 57
End sub
Private sub option5_click ()
Label1.caption = "All texts selected"
Label1.tooltiptext = "All texts selected"
Text1.setfocus
Text1.selstart = 0
Text1.sellength = Len (text1.text)
End sub
The Windows Live write has not been completed, and the code is not so bright. Okay, that's it.
It's strange. There's no such thing as VB below.Programming Language. Put it in the 'object' area!