将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
答案 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