Job Recruitment Website - Zhaopincom - How to realize text box wrapping in VB

How to realize text box wrapping in VB

I was the first to answer, but in order to solve the second and third questions, I changed my answer and became the last one.

1.-

Set the MultiLine property of Text4 to True.

Copy the following code:

Private? Sub? Form_Load()

Text 4. Words? =? ""

End? submarine

Private? Sub? Command 1_Click()

Text 4. Words? =? Text 4. Words? +? Text 1。 Words? +? Text 2. Words? +? SMS 3. Words? +? vbCrLf

End? submarine

The following is to ensure that the focus of Text4 is at the end. Try to remove the following three lines and observe the effect. You will find that these three lines are also important.

Private? Sub? Text4_Change()

Text 4. SelStart? =? Len(Text4。 Text)?

End? submarine

2.-

If you use a list, you can also double-click to copy the contents of the following list items.

Private? Sub? List 1_DblClick()

Clipboard. clear

Clipboard. SetText? List 1。 List (List 1. List index)

MsgBox? This item has been copied to the clipboard. Please paste it with CTRL+V.

End? submarine

3.-

Richtextbox is easier to use than textbox. For example, richtextbox can display different fonts and pictures per line, but its complicated usage is not needed here.

Click on "Engineering" and "Parts" to find "Microsoft? Rich? Text box? Contrast? 6.0 ",click OK, and then you can see it in the tool. Draw RichTextBox 1 on the form?

RichTextBox 1? You don't need to set MultiLine, and the code is written in the same way as Text4.

Copy the following code:

Private? Sub? Form_Load()

RichTextBox 1? =? ""

End? submarine

Private? Sub? Command 1_Click()

RichTextBox 1。 Words? =? RichTextBox 1。 Words? +? Text 1。 Words? +? Text 2. Words? +? SMS 3. Words? +? vbCrLf

End? submarine

Private? Sub? RichTextBox 1_Change()

RichTextBox 1。 SelStart? =? Len(RichTextBox 1。 Text)? Make sure the focus of RichTextBox 1 is at the end.

End? submarine

I have tested the above code, which can be used directly! ! ? Look at the picture!