我有一个VBScript:
Dim Stuff, myFSO, WriteStuff, dateStamp
Stuff = "Whatever you want written"
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set WriteStuff = myFSO.OpenTextFile("C:\Label_1\yourtextfile.txt", 8, True)
WriteStuff.WriteLine(var1)
WriteStuff.Close
SET WriteStuff = NOTHING
SET myFSO = NOTHING
放置在密钥中。 在变量“var1”中读取条形码读取器,条形码EAN13并在按下一个键到文本文件“C:\ Label_1 \ yourtextfile.txt”之后 被写入一个值为“var1”的新行,即。条形码
2914750018247
然后,我们将扫描条形码
2914750007463
然后按按钮 也将保存在文本文件中。
录音将如下所示:
2914750018247
2914750007463
当然,扫描的文件“C:\ Label_1 \ yourtextfile.txt”会更多,例如。 70种不同的代码但总是EAN13。
如何使用VBScript复制或分发5个字符:
01824
00746
...
先前存储了文件“C:\ Label_1 \ yourtextfile.txt”中的所有值(每个5个字符)但当代码(每个包含5个字符)将只有70时,它们都会相加并保存新文件txt在线?
答案 0 :(得分:1)
看一下下面的例子,它处理源文件的行并将每一行切成子串:
sSrc = "C:\Users\DELL\Desktop\barcode.txt"
sDst = "C:\Users\DELL\Desktop\barcode_part.txt"
' Read content of the source file
sCont = ReadTextFile(sSrc, 0) ' ASCII
' Split source file string into array of lines
aLines = Split(sCont, vbCrLf)
' Loop through each of the lines in array
For i = 0 To UBound(aLines)
' Change the value of the element to cut substring
aLines(i) = Mid(aLines(i), 8, 5)
Next
' Join processed array into resulting string with line breaks
sCont = Join(aLines, vbCrLf)
' Write content to the destination file
WriteTextFile sCont, sDst, 0 ' ASCII
Function ReadTextFile(sPath, lFormat)
' lFormat -2 - System default, -1 - Unicode, 0 - ASCII
With CreateObject("Scripting.FileSystemObject").OpenTextFile(sPath, 1, False, lFormat)
ReadTextFile = ""
If Not .AtEndOfStream Then ReadTextFile = .ReadAll
.Close
End With
End Function
Sub WriteTextFile(sContent, sPath, lFormat)
' lFormat -2 - System default, -1 - Unicode, 0 - ASCII
With CreateObject("Scripting.FileSystemObject").OpenTextFile(sPath, 2, True, lFormat)
.Write sContent
.Close
End With
End Sub