\r\n\r\n
Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Save mutliple lines in notepad


\r\n \r\n
 
 
Thread Tools Display Modes

\r\n\r\n\r\n
Hi all,
\n
\nI know how to save a single line to notepad, however, i want to save mutliple lines by entering For Next.
\n
\nHere is the code that i have:
\n
\r\n
Code:
\r\n
Dim FileNum As Integer, NewTxt As String, InputString As String, LineCount As Integer\nDim Number As Integer\n    \nDataFile = "L:\\Fin_Services\\Exchequer S&D\\S&D Log Live\\New Folder\\1(1).txt"\nLineCount = 0\nCurDate = Format(Now, "ddmmyyyy")\nFileCount = 8\nFileNum = FreeFile  \' next free filenumber\nOpen DataFile For Input As #FileNum\n\nWhile Not EOF(FileNum)\n           \nLine Input #FileNum, InputString \' read a line from the textfile\nFor Number = 1 To FileCount\n\n    \nNewTxt = "BCMS$" & CurDate & "$$IDXCRORB$SYSADM$Benefit-CMS Input  DOC$f:\\dwpimports\\1(" & LineCount & ").pdf"\nLineCount = LineCount + 1\nNext Number\nWend\n        \nClose #FileNum\n\nFileNum = FreeFile  \' next free filenumber\nOpen DataFile For Append As #FileNum\n\n    Print #FileNum, NewTxt\n    Close #FileNum
\r\n
This just overwrites one line with the new string.
\n
\nI think i have the For and Next in the wrong places.
\n
\nAny ideas?
\r\n \r\n\r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n \r\n
\r\n
\r\n \r\n \r\n Last edited by Flyguy; 02-17-2010 at 05:16 AM.\r\n \r\n \r\n Reason: Added [code][/code] tags\r\n \r\n \r\n
\r\n \r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[1354448] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 02-17-2010, 04:13 AM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
Flyguy\'s Avatar\r\n\r\n
\r\n \r\n Flyguy\r\n Flyguy is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 02-17-2010, 03:43 AM
eagles4519 eagles4519 is offline
Freshman
 
Join Date: Jan 2009
Posts: 44
Question Save mutliple lines in notepad


Hi all,

I know how to save a single line to notepad, however, i want to save mutliple lines by entering For Next.

Here is the code that i have:
Code:
Dim FileNum As Integer, NewTxt As String, InputString As String, LineCount As Integer
Dim Number As Integer
    
DataFile = "L:\Fin_Services\Exchequer S&D\S&D Log Live\New Folder\1(1).txt"
LineCount = 0
CurDate = Format(Now, "ddmmyyyy")
FileCount = 8
FileNum = FreeFile  ' next free filenumber
Open DataFile For Input As #FileNum

While Not EOF(FileNum)
           
Line Input #FileNum, InputString ' read a line from the textfile
For Number = 1 To FileCount

    
NewTxt = "BCMS$" & CurDate & "$$IDXCRORB$SYSADM$Benefit-CMS Input  DOC$f:\dwpimports\1(" & LineCount & ").pdf"
LineCount = LineCount + 1
Next Number
Wend
        
Close #FileNum

FileNum = FreeFile  ' next free filenumber
Open DataFile For Append As #FileNum

    Print #FileNum, NewTxt
    Close #FileNum
This just overwrites one line with the new string.

I think i have the For and Next in the wrong places.

Any ideas?

Last edited by Flyguy; 02-17-2010 at 05:16 AM. Reason: Added [code][/code] tags
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->