0

将 VB6.0 代码转换为 VB.Net 代码后,出现错误“FileName”不是“System.Windows.Forms.RichTextBox”的成员。

转换后的VB6代码-

Public WithEvents rtfLicenseFile As System.Windows.Forms.RichTextBox    

Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click
    If Not rtfLicenseFile.ReadOnly Then
        rtfLicenseFile.SaveFile(rtfLicenseFile.FileName, Windows.Forms.RichTextBoxStreamType.PlainText)
        System.Windows.Forms.Application.DoEvents()
        Sleep(1000)
    End If
    Me.Close()
End Sub
4

1 回答 1

1

这是因为FileName不是System.Windows.Forms.RichTextBox的成员。使用变量来存储文件名。

例如使用您的代码:

Public WithEvents rtfLicenseFile As System.Windows.Forms.RichTextBox
Public strFileName As String = "C:\Test.txt"

Private Sub cmdClose_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdClose.Click
    If Not rtfLicenseFile.ReadOnly Then
        rtfLicenseFile.SaveFile(strFileName, Windows.Forms.RichTextBoxStreamType.PlainText)
        System.Windows.Forms.Application.DoEvents()
        Sleep(1000)
    End If
    Me.Close()
End Sub
于 2013-09-10T10:37:04.117 回答