【发布时间】:2014-09-19 04:31:38
【问题描述】:
我在 VB 中有一个 Windows 窗体应用程序 我想条件是,如果参数是通过命令行传递的,那么表单不应该显示。 我不确定为什么以下代码不起作用 任何建议将不胜感激 谢谢 戴维
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim args As String() = Environment.GetCommandLineArgs()
MsgBox(args.count())
If args.Count() > 1 Then
If args(1) = "delete" Then
If args.Count() = 3 Then
deletepage(args(2), args(5))
Close()
End If
ElseIf args(1) = "add" Then
If args.Count() >= 5 Then
addpage(args(2), args(3), args(4), args(5))
Close()
End If
End If
End If
loadnames()
End Sub
消息框出现并显示 5(传递了 5 个参数) 但是随后程序完全忽略了 if 语句,并提出了表单??
【问题讨论】:
-
您是否调试过检查 arg() 中返回的值?它接近尾声了吗?考虑将后者替换为 Me.Close()
标签: vb.net forms onload-event