使用VBA输出到文本框时出现问题 [英] Problem outputting to text box using VBA

查看:262
本文介绍了使用VBA输出到文本框时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个非常容易回答的问题:


我一直在输出一些文本到消息框,类似于以下内容:

This is probably a very easy question to answer:

I have been outputting some text to a message box, similar to the following:

展开 | 选择 | Wrap | 行号

推荐答案

嗨。您实际上并没有将字符串输出到文本框,而是输出到其关联的标签(通过使用标题属性)。据我所知,标签不是为了显示多行字符串,因此您的换行问题。


您应该会发现实际的文本框正确显示多行字符串。要将文本框本身设置为字符串,只需使用


txtBox = strOutput


您需要垂直调整文本框的大小以查看第二个正确的后续行。


-Stewart


ps有一个vb常量vbCrLf可用来代替你的Chr(10)将完整的回车符和换行符组合插入到字符串中。如果Chr(10)没有,你可能会发现这是可靠的。
Hi. You are not actually outputting the string to the textbox, but to its associated label (by use of the caption property). As far as I know labels are not intended to display multi-line strings, hence your problem with the line feed.

You should find that the actual text box displays multi-line strings correctly. To set the textbox itself to the string, simply use

txtBox = strOutput

You will need to resize the textbox vertically to see the second and subsequent lines correctly.

-Stewart

ps there is a vb constant vbCrLf which you can use in place of your Chr(10) to insert a complete carriage-return and line-feed combination into the string. You may find that this works reliably if the Chr(10) does not.


**新闻**


斯图尔特让我无话可说 - 再次!


/ **新闻**


我只会进一步强调使用vbCRLF(和/或相关的vbCR和vbLF常量) )是推荐的引用这些字符的方法。它使得代码更容易阅读,如果没有别的。
** NEWS **

Stewart leaves me nothing to say - AGAIN!

/** NEWS **

I would only stress further that using vbCRLF (and/or associated vbCR and vbLF constants) is a recommended way to refer to these characters. It makes the code more easily readable if nothing else.


实际上标签上的标题可以是多行的。


如前所述,请使用vbCrLF而不是chr(10)然后你必须设置标签的高度以容纳所有的行。如果您的高度没有设置为容纳所有线条,它将只显示1行或标签中显示的数量。


我一直创建多行标签。我也运行你的代码并替换了vbCRLF,它对我有用。


欢呼,

Actually Captions on labels CAN be multi lined.

As the previous posts say use the vbCrLF instead of chr(10) and then you MUST set the height of your label to accomodate all the lines. If your height is not set to accomodate all the lines it will just show 1 line or as many as it can show in the label.

I create multi line labels all the time. I also ran your code and substituted vbCRLF and it works for me.

cheers,


这是可能是一个非常容易回答的问题:


我一直在输出一些文本到消息框,类似于以下内容:

This is probably a very easy question to answer:

I have been outputting some text to a message box, similar to the following:

展开 | 选择 | Wrap | 行号


这篇关于使用VBA输出到文本框时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆