简体   繁体   English

Excel Vba文本框段落

[英]Excel Vba Textbox Paragraph

I am creating a textbox that will work only as a guide-line, my textbox has multiline and enterkeybehaviour= True. 我正在创建一个仅用作指南的文本框,我的文本框具有多行且enterkeybehaviour = True。

TextBox2 gets value from TextBox1 , now I have TextBox2 = TextBox1, I need a Carriage Return so the next inputed value will go to TextBox2 second line. TextBox2从TextBox1获取值,现在我有TextBox2 = TextBox1,我需要回车,所以下一个输入的值将转到TextBox2的第二行。

Example , i write something on TextBox1 and press Enter and the text will go to TextBox2 and do a paragraph. 例如,我在TextBox1上写一些东西,然后按Enter键,文本将转到TextBox2并做一个段落。 Can't be no overwriting as the process can be repeated. 不能重复,因为过程可以重复。

Insert a carriage return wit constant vbCr . 插入回车符和常量vbCr

myString = "First line." & vbCr & "Second line."

If you want a Line Feed instead of a Carriage Return, it's vbLf . 如果要换行而不是回车, vbLf Both combined are vbCrLf . 两者组合都是vbCrLf

TextBox2.Text = TextBox1.Text & VbLf & "Something"

or 要么

TextBox2.Text = TextBox1.Text & chr(13) & "Something"


And some minimal example: 还有一些最小的例子:

Option Explicit

Sub TestMe()

    Dim someVar As String
    someVar = "ale"
    someVar = someVar & vbLf & "Something"

    MsgBox someVar

End Sub

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM