编码器z相应用:visual basic 2005代码的意思

来源:百度文库 编辑:高校问答 时间:2024/04/27 22:54:59
请教visual basic 2005代码
Private Sub ParseCommandLineArgs()
Dim inputArgument As String = "/input="
Dim inputName As String = ""

For Each s As String In My.Application.CommandLineArgs
If s.ToLower.StartsWith(inputArgument) Then
inputName = s.Remove(0, inputArgument.Length)
End If
Next

If inputName = "" Then
MsgBox("No input name")
Else
MsgBox("Input name: " & inputName)
End If
End Sub

这段代码如何解释?
谢谢|

这是一个处理命令行参数的过程,我们知道有的应用程序可以在dos状态下输入参数运行程序,如:java a.class -c (其中-c为参数),ParseCommandLineArgs这个过程就是读取命令行参数并加以处理的过程.而且输入的命令行参数有时候不只一个,有可能多个,一般使用空格把多个参数分开。如:java a.class -c -x.所以在ParseCommandLineArgs过程中,用了一个循环对每一个参数都进行了判断。
For Each s As String In My.Application.CommandLineArgs
.....
next
这个循环的作用就是读取每一个参数,中间的省略号就是对读取的一个参数的判断过程