2013-07-07 78 views
0

我正在尋找一個腳本,以便從17個字符長的數字中輸出大量的連續數字(每次一百萬)。 (EG 12345678912345678)VBScript中的數字序列生成

我基本上希望它像這個網站(http://sequencegenerator.com)工作,但使用我的CPU而不是他的。當我告訴它做了一百萬美元時,他的網站就鎖定了,而且我傾向於每次創造數百萬美元。

我從網上找到了這個腳本,但我不知道任何VisualBasic,所以我不確定如何使它適用於我。

Set WSHShell = Wscript.CreateObject("WScript.Shell")  
Set FSO = Wscript.CreateObject("Scripting.FileSystemObject") 
Set EnvVar = wshShell.Environment("Process") 
tBestand= EnvVar("USERPROFILE") & "\Desktop\HexNumbers.txt" 
Set Bestand = fso.createtextfile(tBestand,1) 
For x = 1486262272 To 1486461337 
Bestand.WriteLine(hex(x)) 
Next 
Bestand.close 
WScript.quit 

回答

3

爲了避免與VBScript的雙人/貨幣數量的可靠範圍內的所有問題,分裂您的起始編號(串)轉換成穩定的/永遠不會改變前綴和一個長的數字尾巴被遞增:

Option Explicit 

Dim sStart : sStart = "123456789" 
Dim nCount : nCount = 20 

Dim sPfx : sPfx = Left(sStart, 10) 
Dim nStart : nStart = CLng(Mid(sStart, 11)) 
Dim n 
For n = 1 To nCount 
    WScript.Echo sPfx, nStart, sPfx & nStart 
    nStart = nStart + 1 
Next 

輸出:

1234567890 1234567 123456789
1234567890 1234568 123456789
1234567890 1234569 123456789
1234567890 1234570 123456789
1234567890 1234571 123456789
1234567890 1234572 123456789
1234567890 1234573 123456789
1234567890 1234574 123456789
1234567890 1234575 123456789
1234567890 1234576 123456789
1234567890 1234577 123456789
1234567890 1234578 123456789
1234567890 1234579 123456789
1234567890 1234580 123456789
1234567890 1234581 123456789
1234567890 1234582 123456789
1234567890 1234583 123456789
1234567890 1234584 123456789
1234567890 1234585 123456789
1234567890 1234586 123456789
+0

嗯,有一個好主意xD我如何使這個輸出到文本文件而不是回聲? – SuperMar1o

+0

稍作修改,但現在效果很好。謝謝! – SuperMar1o

1

Ekkehard.Horner的稍作修改腳本。按我想要的方式工作。謝謝!

Option Explicit 
Dim sStart : sStart = "1234567891234567" 
Dim nCount : nCount = 1000000 
Dim sPfx : sPfx = Left(sStart, 10) 
Dim nStart : nStart = CLng(Mid(sStart, 11)) 
Dim n 
For n = 1 To nCount 

Dim fs 
Set fs = CreateObject("Scripting.FileSystemObject") 
Dim objLog 
set objLog = Fs.OpenTextFile("Numbers.txt", 8, true, 0) 
objLog.WriteLine sPfx & nStart 
objLog.close 

nStart = nStart + 1 
Next