未找到方法或数据成员
当我运行我的代码时出现此错误。这是这篇文章的延续: 向标签添加滚动条
我首先创建了一个 userForm从工作表中检索信息的标签。我想要添加一个滚动条,以便我可以在标签中查看列表(如果列表比标签长)。有人告诉我尝试使用文本框。我从代码中取出了这一行:
reportDate.Caption = reportDate.Caption & Sheets("DATA2").Range("P" & rowNum).Text & vbCrLf
并复制了它,并在文本框后面添加了一个数字 1,因此文本框的代码是:
reportDate1.Caption = reportDate1.Caption & Sheets("DATA2").Range("P" & rowNum).Text & vbCrLf
正是这一行出现了错误(帖子的标题)。
I get this error when I run my code. This is a continuation from this post:
Adding a scroll bar to a label
I first created a userForm that had labels that retrieved information from a worksheet. I wanted a scroll bar added so that I could view the list in the label if it was longer than the label. I was told to try a text box. I took this line from my code:
reportDate.Caption = reportDate.Caption & Sheets("DATA2").Range("P" & rowNum).Text & vbCrLf
and copied it and just added a number 1 after it for the text box so the code for the text box is:
reportDate1.Caption = reportDate1.Caption & Sheets("DATA2").Range("P" & rowNum).Text & vbCrLf
It is this line where there is an error (the title of the post).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否创建了一个名为
reportDate1
的文本框对象,或者只是复制了代码?如果模块顶部没有名为
reportDate1
的对象,并且没有变量Dim
ed,并且没有Option Explicit
语句,则reportDate1< /code> 将是一个变体,它没有标题方法或属性,
附近有一些奇怪的东西...下面是开发模式和运行模式下的简单测试用例的屏幕截图。文本是任意字符串,没有换行符。版本/操作系统可能是一个问题?我使用的是 Windows Excel 2010。
Did you create a text box object called
reportDate1
or just copy the code?If there is no object called
reportDate1
and no variableDim
ed and noOption Explicit
statement at the top of the module thenreportDate1
will be a variant, which has no Caption Method or propertySomething starnge in the neighbourhood... below is a screen shot of a simple test case in developement mode and run mode. Text is an arbitary string, no line breaks. Version/OS may be an issue? I used Windows Excel 2010.
您是否在表单上创建了一个名为reportDate1 的对象?
And did you create an object named reportDate1 on your form?