如何解决代码转换问题?
How to solve code conversion issue?
Public Function SaveCommentsTreeComments(ByRef f As System.Windows.Forms.Form) As Integer
Dim IsNewSubComment As Boolean
Dim IsNewCommentWithSub As Boolean
Dim sql As String
Dim rs As New ADODB.Recordset
Dim CommentID As Short
Dim SubCommentID As Short
Dim Index As Short
'WMB 1/28/2004 nextval
Dim cSql As String
Dim cRs As New ADODB.Recordset
Dim cSeq As Double
On Error GoTo SaveCommentsTreeCommentsError
SaveCommentsTreeComments = -1
If Not ValidateCommentsTreeComments(f) Then
SaveCommentsTreeComments = -2
Exit Function
End If
If f.CommentsText(CommentsTextAbbreviation).Enabled And f.CommentsText(SubCommentsTextDescription).Enabled Then
IsNewCommentWithSub = False
我在将上面的代码从 vb6 升级到 vb.net 时收到以下错误。我不知道缺少哪个 class。
'CommentsText' is not a member of 'System.Windows.Forms.Form'
你应该改变:
Public Function SaveCommentsTreeComments(ByRef f As System.Windows.Forms.Form) As Integer
收件人:
Public Function SaveCommentsTreeComments(f As YourFormClassName) As Integer
这改变了两件事,首先 f 现在是正确的类型并且有一个 CommentsText
属性,字段或函数。其次,在传递参数时,VB6 的默认值是 ByRef,开发 VB.NET 时,他们意识到这是一个错误并更正了它,但是转换没有进行必要的分析来确定是否需要 ByRef。由于在这种情况下没有必要,因此应将其删除或更改为 ByVal。
Public Function SaveCommentsTreeComments(ByRef f As System.Windows.Forms.Form) As Integer
Dim IsNewSubComment As Boolean
Dim IsNewCommentWithSub As Boolean
Dim sql As String
Dim rs As New ADODB.Recordset
Dim CommentID As Short
Dim SubCommentID As Short
Dim Index As Short
'WMB 1/28/2004 nextval
Dim cSql As String
Dim cRs As New ADODB.Recordset
Dim cSeq As Double
On Error GoTo SaveCommentsTreeCommentsError
SaveCommentsTreeComments = -1
If Not ValidateCommentsTreeComments(f) Then
SaveCommentsTreeComments = -2
Exit Function
End If
If f.CommentsText(CommentsTextAbbreviation).Enabled And f.CommentsText(SubCommentsTextDescription).Enabled Then
IsNewCommentWithSub = False
我在将上面的代码从 vb6 升级到 vb.net 时收到以下错误。我不知道缺少哪个 class。
'CommentsText' is not a member of 'System.Windows.Forms.Form'
你应该改变:
Public Function SaveCommentsTreeComments(ByRef f As System.Windows.Forms.Form) As Integer
收件人:
Public Function SaveCommentsTreeComments(f As YourFormClassName) As Integer
这改变了两件事,首先 f 现在是正确的类型并且有一个 CommentsText
属性,字段或函数。其次,在传递参数时,VB6 的默认值是 ByRef,开发 VB.NET 时,他们意识到这是一个错误并更正了它,但是转换没有进行必要的分析来确定是否需要 ByRef。由于在这种情况下没有必要,因此应将其删除或更改为 ByVal。