我有一份申请表。我之前没有必须使用命令行参数,但我的研究表明我的方法并不错。在VS2015中,在我的项目属性 - > debug中我添加了/boxID=123
,但是当我调试时,我的inputVal变量中什么都没有。我哪里错了?
Imports Word = Microsoft.Office.Interop.Word 'needed for COM object interaction with MS Word
Imports System.Data.SqlClient 'needed for DB interactions
Imports System.IO 'needed for BLOB
Public Class Window
'set form level declarations
Dim appPath As String
Dim objWordApp As New Word.Application
Dim objDoc As Word.Document
Function boxIDfromCommandLine() As Integer
Dim inputArg As String = "/boxID="
Dim inputVal As String = ""
For Each s As String In My.Application.CommandLineArgs
If s.ToLower.StartsWith(inputArg) Then
inputVal = s.Remove(0, inputArg.Length)
End If
Next
If inputVal = "" Then
inputVal = "0"
End If
boxIDfromCommandLine = Convert.ToInt32(inputVal)
End Function
'form load subroutine
Private Sub Window_Load(ByVal sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Establish application path, replace appPath on deployment
Dim appPath As String = Application.StartupPath()
'Run application in foreground or background.
'If in background (false), be sure to add objDoc.close() and objWordApp.Quit()
objWordApp.Visible = False
'Declarations
Dim localDateTimeString As String = DateTime.Now.ToString
Dim localDateTimeFileName As String = DateTime.Now.ToString("yyyyMMddhhmm")
Dim soNumber As String = "No_SO_Selected"
Dim boxID As Integer = boxIDfromCommandLine()
Dim saveString As String 'file name format
Dim savePath As String = "C:\ITO_PackingLists" 'set folder location
Dim connection As SqlConnection = New SqlConnection() 'set SQL server connection string
... ... ...