我正在将VB6.0应用程序升级到VB.Net。
Visual Studio Express 2005自动升级,但仍有一些代码无法升级。
这些主要是CommDiag问题。如果有人可以就如何在VB.NET中编写它提出建议。我只是VB.net的首发。
以下是代码:
Public Function open_file(ByRef form_name As System.Windows.Forms.Form, ByRef file_name As String, ByVal file_type As String, ByRef mode As String, ByRef cap As String, ByRef choice As Boolean) As Byte
Dim Msg As String 'used to save error messages for the msgbox command
Dim fileNum As Short 'used to get the next available file number
'*** handle all errors in the error handler routine
On Error GoTo open_error_handler
If (choice = True) Or (file_name = "") Then
'*** handle the cancel button seperate
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.CancelError = True
'*** set the 'prompt for overwrite flag' for save dialogs
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.Flags = &H2s
'*** setup the fields for the common dialog control
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.fileName = file_name
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.DefaultExt = Right(file_type, 3)
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.Filter = file_type
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.DialogTitle = cap
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.InitDir = basFunctionsIniRegistry.ReadINIString("Default Directories", file_type, "c:\", iniFileLocation)
Select Case mode
Case "output"
'*** display the save box if we'll be writting to the file
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.ShowSave()
Case "input", "open", "append"
'*** display the open box
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
form_name.CommDiag.ShowOpen()
End Select
'UPGRADE_ISSUE: Control CommDiag could not be resolved because it was within the generic namespace Form. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="084D22AD-ECB1-400F-B4C7-418ECEC5E36E"'
file_name = form_name.CommDiag.fileName
End If
'*** get next available file number
fileNum = FreeFile
End Function
答案 0 :(得分:0)
我试过,我希望以下是我们可以使用OpenFileDialog,SaveFileDialog类代替CommDiag上面代码的方式
Public Function open_file(ByRef form_name As System.Windows.Forms.Form, ByRef file_name As String, ByVal file_type As String, ByRef mode As String, ByRef cap As String, ByRef choice As Boolean) As Byte
Dim Msg As String 'used to save error messages for the msgbox command
Dim fileNum As Short 'used to get the next available file number
'*** handle all errors in the error handler routine
On Error GoTo open_error_handler
If (choice = True) Or (file_name = "") Then
'*** handle the cancel button seperate
Select Case mode
Case "output"
Dim saveFileDialog1 As New SaveFileDialog()
saveFileDialog1.InitialDirectory = basFunctionsIniRegistry.ReadINIString("Default Directories", file_type, "c:\", iniFileLocation)
saveFileDialog1.Filter = file_type
saveFileDialog1.FilterIndex = 2
saveFileDialog1.DefaultExt = Right(file_type, 3)
saveFileDialog1.FileName = file_name
saveFileDialog1.Title = cap
saveFileDialog1.ShowDialog()
Case "input", "open", "append"
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = basFunctionsIniRegistry.ReadINIString("Default Directories", file_type, "c:\", iniFileLocation)
openFileDialog1.Filter = file_type
openFileDialog1.FilterIndex = 2
openFileDialog1.DefaultExt = Right(file_type, 3)
openFileDialog1.FileName = file_name
openFileDialog1.Title = cap
openFileDialog1.ShowDialog()
End Select
file_name = form_name.CommDiag.fileName
End If
'*** get next available file number
fileNum = FreeFile
End Function