vb6到vb.net的转换' FileName'不是System.Windows.Forms.RichTextBox'的成员。

时间:2013-09-10 10:29:39

标签: vb.net vb6

将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

1 个答案:

答案 0 :(得分: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