我創建一個腳本來分裂的CSV文件,我希望讓用戶輸入其文件被分割成新的區間。的VBScript用戶輸入變量
我遇到的問題是,當我輸入的時間間隔是不分裂的,但還沒有,如果我硬編碼在它的價值不會分裂。
Option Explicit
Const ForReading = 1
Const ForWriting = 2
Dim objFSO, objInputFile, objOutputFile
Dim intLine, intFile
Dim strHeaders
Dim strInputFile, strOutputPrefix, strLine
Dim MyDate
Dim userSplit
Dim split
'strInputFile = InputBox("Enter file location")
strInputFile = "H:\VBS\domS_CUST.csv"
strOutputPrefix = strInputFile & DatePart("yyyy", Now) & "-" & DatePart("m", Now) & "-" & DatePart("d", Now)
intFile = 1
intLine = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objInputFile = objFSO.OpenTextFile(strInputFile, ForReading)
If (objInputFile.AtEndOfStream = True) Then
' The file is empty
WScript.Quit 1
End If
strHeaders = objInputFile.ReadLine
userSplit = InputBox("Enter when you want to split")
Do While (objInputFile.AtEndOfStream = False)
split = userSplit
strLine = objInputFile.ReadLine
If (intLine <= 0) Then
Set objOutputFile = objFSO.CreateTextFile(strOutputPrefix & "_" & intFile & ".csv", True)
objOutputFile.WriteLine strHeaders
intLine = 1
End If
objOutputFile.WriteLine strLine
If (intLine >= split) Then
objOutputFile.Close
Set objOutputFile = Nothing
intFile = intFile + 1
intLine = 0
Else
intLine = intLine + 1
End If
Loop
輸入是這一行:
userSplit = InputBox("Enter when you want to split")
,我似乎無法得到它在這個值分割,任何幫助將不勝感激!
你有沒有考慮[鑄造](http://www.pctools.com/guides/scrip ting/id/200 /?act = reference)你的字符串表達式是一個數字嗎? – 2013-08-12 09:14:17