button - 用按钮复制对象vb6
问题描述
项目结构和UserControl
:
Formularios = Form = Form1
Controles de Usuario = User Controls = uc1
所有UserControl
代码:
Option Explicit
Public Property Get AddType() As String
AddType = cmbAddExample.Text
End Property
Public Property Let AddType(ByVal Value As String)
cmbAddExample.Text = Value
End Property
Public Property Get AddNumber() As String
AddNumber = Text1.Text
End Property
Public Property Let AddNumber(ByVal Value As String)
Text1.Text = Value
End Property
Button
添加(Añadir)代码:
Option Explicit
Dim indice As Integer
Private Sub btnAñadir_Click()
indice = indice + 1
Load uc1(indice)
Set uc1(indice).Container = Picture1
uc1(indice).Visible = True
uc1(indice).Top = IIf(indice = 1, 0, uc1(indice - 1).Top + uc1(indice - 1).Height + 20)
Load cmbAddExample(indice)
Set cmbAddExample(indice).Container = uc1(indice)
cmbAddExample(indice).Visible = True
cmbAddExample(indice).Top = cmbAddExample(indice - 1).Top
CargaIDTipoNumero
Load Text1(indice)
Set Text1(indice).Container = uc1(indice)
Text1(indice).Visible = True
Text1(indice).Top = Text1(indice - 1).Top
uc1(indice).AddType = uc1(0).AddType
uc1(indice).AddType = ""
Picture1.Visible = True
If indice = 3 Then
Me.btnAñadir.Enabled = False
End If
End Sub
黑圈是一个UserControl
有一个TextBox
和一个ComboBox
里面。红圈是一个PictureBox
。
所以,问题是PictureBox
当我按下按钮添加时,我需要从 uc1 复制值。但是当我按下按钮时,它会显示下一个错误:
Compilation Error: Method or data member not found.
在这一行:
uc1(index).AddType = uc1(0).AddType
那么,有什么好办法吗?
解决方案
在您的帖子中,您说用黑色圈出的对象是一个 UserControl,而实际上它是一个名为uc1(0)
. 由于 PictureBox 没有 AddType 属性,您会收到错误消息。
用 UserControl 替换此 PictureBox 将解决该错误。
推荐阅读
- r - 如何在等高线图 R-Plotly 中手动设置色标?
- excel - 如何在 VBA Excel 中打开和保存 XML UTF8 unix 文件?
- python - 取对象数组的std
- javascript - 使用类名选择器识别元素,但使用此关键字时不识别
- c# - 如何向 AbpODataEntityController 添加自定义函数?
- postgresql - 大型数据库上的 pg_dump 和 pg_restore
- c# - ServicePointManager.FindServicePoint 块
- mysql - 直接在 MySQL Workbench 中启动 MySQL 命令行客户端
- python - 使用 Python 解析和拆分 .txt 文件并导出为 .csv 行
- c++ - 从 Visual Studio 启动时,发布构建比“正常”启动时更快