代码在vb.net中显示为跳转行
我有一段代码看起来像是“跳转”代码在vb.net中显示为跳转行,vb.net,winforms,Vb.net,Winforms,我有一段代码看起来像是“跳转” Public Sub New() ' This call is required by the designer. InitializeComponent() SU_DefaultLoc.Text = My.Settings.DefaultLocation If My.Settings.DefaultLocation = "" Or File.Exists(My.Settings.DefaultLocation) = False
Public Sub New()
' This call is required by the designer.
InitializeComponent()
SU_DefaultLoc.Text = My.Settings.DefaultLocation
If My.Settings.DefaultLocation = "" Or File.Exists(My.Settings.DefaultLocation) = False Then
MsgBox("start")
My.Settings.DefaultLocation = FileBrowse(My.Settings.DefaultLocation)
MsgBox(My.Settings.DefaultLocation)
My.Settings.Save()
End If
If My.Settings.SaveLocation = "" Then
My.Settings.SaveLocation = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
My.Settings.Save()
End If
SU_DefaultLoc.Text = My.Settings.DefaultLocation
Me.Text = "Delivery Scheduling - Version " & Me.ProductVersion
My.Settings.UpdateLoad = False
My.Settings.Save()
LoadDatasets()
End Sub
代码正确运行以显示msgbox(“开始”)
然后,它会提供浏览对话框(在下一行代码上),但随后会出现执行行LoadDatasets()
(就在End Sub
的上方)
此子例程(LoadDatasets()
)有一个try,catch语句,catch上有一个messagebox,下面将显示此messagebox
单击OK(在LoadDatasets()中的msgbox上)后,将在第10行显示msgbox(My.Settings.DefaultLocation)
FileBrowse()
代码如下:
Function FileBrowse(Optional Location As String = "", _
Optional Title As String = "Browse to the folder that stores the import files and click 'Open'") As String
If Location = "" Then Location = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
'Show Browse Info
With FBD
.InitialDirectory = Replace(Location, Split(Location, "\").ElementAt(UBound(Split(Location, "\"))), "")
.Title = Title
End With
If FBD.ShowDialog() = Windows.Forms.DialogResult.OK Then
'clear old settings
My.Settings.VanLoadDetails.Clear()
My.Settings.OrderData.Clear()
My.Settings.UpdateLoad = False
FileBrowse = FBD.FileName
LoadDatasets()
Else
'Do Nothing
FileBrowse = ""
End If
End Function
有什么想法吗?可能代码“似乎在执行LoadDatasets()
”,因为FileBrowse
实际上调用了LoadDatasets()
函数FileBrowse(可选位置为String=“”_
可选标题为String=“浏览到存储导入文件的文件夹,然后单击“打开”),标题为String
如果Location=”“,则Location=Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
'显示浏览信息
用FBD
.InitialDirectory=Replace(位置,拆分(位置“\”).ElementAt(UBound(拆分(位置“\”))),“”)
.头衔=头衔
以
如果FBD.ShowDialog()=Windows.Forms.DialogResult.OK,则
...
LoadDatasets()'出现跳跃的是什么意思?你在调试它吗?它只是不运行代码吗?我应该说的是它似乎在执行LoadDatasets()行-我已经更正了q。我正在调试它。我想FileBrowse()方法是在另一个线程中执行的。@Nadeem_MK我已经添加了FileBrowse代码,openfiledialog(FBD)是否没有与FBD.showdialog()一起以模式显示?有时我会惊讶于自己有多愚蠢!非常感谢。
Function FileBrowse(Optional Location As String = "", _
Optional Title As String = "Browse to the folder that stores the import files and click 'Open'") As String
If Location = "" Then Location = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
'Show Browse Info
With FBD
.InitialDirectory = Replace(Location, Split(Location, "\").ElementAt(UBound(Split(Location, "\"))), "")
.Title = Title
End With
If FBD.ShowDialog() = Windows.Forms.DialogResult.OK Then
...
LoadDatasets() ' <--- here'
Else
...
End Function