【发布时间】:2018-10-22 14:40:44
【问题描述】:
我已将 VB6 控件迁移到 Vb.Net,当我启用了 option strict 时,我收到“Option Strict On 不允许后期绑定”错误。下面我已经详细提到了VB6代码以及迁移代码。
VB6 代码:-
Private m_colRows As Collection 'Represents the rows in a table
Private m_lngCurrCol As Long 'Control variable for Col Property
Private m_lngCurrRow As Long 'Control variable for Row Property
Public Property Let CellText(ByVal strText As String)
m_colRows(m_lngCurrRow)(m_lngCurrCol).Text = strText
End Property
Public Property Get CellText() As String
CellText = m_colRows(m_lngCurrRow)(m_lngCurrCol).Text
End Property
以下是迁移后的代码(Vb.Net)
Public Property CellText() As String
Get
CellText = m_colRows.Item(m_lngCurrRow)(m_lngCurrCol).Text
End Get
Set(ByVal Value As String)
m_colRows.Item(m_lngCurrRow)(m_lngCurrCol).Text = Value
End Set
End Property
Option Strict On 不允许后期绑定,我需要帮助修改代码以使用它。
【问题讨论】:
-
你是如何在VB.NET中定义m_colRows的?
-
@steve :- 我这样定义 :- Private m_colRows As Collection
-
如果 Item 返回一个对象,您需要将其转换为正确的类。
标签: vb.net vb6-migration