如何在VB6中限制添加重复项
我有一个用VB6编写的应用程序 此应用程序包含一个包含foreach循环的代码段的文件。在这个循环中,有一个方法将控件添加到报告中的某个区域 我正在尝试实现以下功能: 当Header添加到headerSection中时,tt将不会再次添加Header,但是此代码段无法执行此操作。我哪里做错了如何在VB6中限制添加重复项,vb6,activereports,componentone,Vb6,Activereports,Componentone,我有一个用VB6编写的应用程序 此应用程序包含一个包含foreach循环的代码段的文件。在这个循环中,有一个方法将控件添加到报告中的某个区域 我正在尝试实现以下功能: 当Header添加到headerSection中时,tt将不会再次添加Header,但是此代码段无法执行此操作。我哪里做错了 For Each thisColumn As Column In theColumns If thisColumn.Type = Column.ColumnType.Description Then
For Each thisColumn As Column In theColumns
If thisColumn.Type = Column.ColumnType.Description Then
AddDescriptionColumn(thisColumn, startColumnAt, headerTop)
End If
Private Sub AddDescriptionColumn(ByVal ColumnToAdd As Column, ByRef LeftPosition As Single, ByVal HeaderTop As Single)
'Get report sections
Dim headerSection As ActiveReports.Section = _theActiveReport.Sections(PageHeaderName)
'Add column header text
Dim theHeader As New ActiveReports.Label
theHeader.Name = "lblDescription"
theHeader.Text = ColumnToAdd.DisplayCaption
theHeader.Font = ColumnToAdd.HeaderFont
theHeader.Location = New PointF(LeftPosition, HeaderTop)
theHeader.Size = New SizeF(columnWidth, _columnHeaderHeight)
If TextHeight(ColumnToAdd.DisplayCaption, theHeader.Font, columnWidth) > _columnHeaderHeight Then
theHeader.VerticalAlignment = ActiveReports.VerticalTextAlignment.Top
Else
theHeader.VerticalAlignment = ActiveReports.VerticalTextAlignment.Bottom
End If
theHeader.BackColor = Color.Transparent
theHeader.MultiLine = True
theHeader.WordWrap = True
theHeader.Visible = True
headerSection.Controls.Add(theHeader)
Dim headerSection As ActiveReports.Section=\u ActivierReport.SectionsPageHeaderName是无效的VB6语法。这是VB.Net源代码吗?这是VB.Net代码而不是VB6代码。SizeF、PointF是.Net类型。对于每个this列,列中的列是VB.Net,在VB6中用作内部ForEach是不合法的。正如wqw所说,在VB6中初始化Dim行上的变量是不合法的