OK, the problem is what I thought it might be. The Len(lngNumber) thing isn't giving the right answer, so the numbers don't line up in the text file. I have no idea how the time of what I'm posting here compares to what we did already, but this will do what you need:
VB Code:
Option Explicit Private Sub Command_Click() Dim i As Long Dim lngMin As Long Dim lngMax As Long Dim iLen As Integer Dim sFilename As String sFilename = App.Path & "\NumberList.txt" iLen = CInt(Text1.Text) lngMin = CLng(Text2.Text) lngMax = CLng(Text3.Text) Open "c:\temp\numbers.txt" For Output As #1 For i = lngMin To lngMax ' number to count to Print #1, LPAD(CStr(i), iLen) Next i Close #1 MsgBox "Finished" End Sub Private Function LPAD(sNumber As String, Length As Integer) As String LPAD = String$(Length - Len(sNumber), "0") & sNumber End Function




Reply With Quote