![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
|
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to read text file Hi Is possible to help me to read a text file, line by line, and place it into an arry? code VBScript 'Text file opened with notepad 25-07-2008 20:34:35 I/OManager Alto Routing error1 : Low 25-07-2008 20:34:36 I/OManager Alto Routing error7 : Low 25-07-2008 20:34:36 I/OManager Alto Routing error2 : Low 25-07-2008 20:34:36 I/OManager Alto Routing error2 : Low 25-07-2008 20:34:36 I/OManager Alto Routing error3 : Low 25-07-2008 20:34:38 I/OManager Alto Routing error6 : Low 25-07-2008 20:34:40 I/OManager Alto Routing error 8: Low 25-07-2008 20:34:42 I/OManager Alto Routing error1 : Low Thank you in advance H.S. |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: How to read text file "henrique" <qwqwq@xxxxxx> wrote in message news:94C154D2-0BBC-41AD-B89E-043BCA49CE75@xxxxxx
CRLF = Chr(13) & Chr(10) sFileName = "d:\temp\test.txt" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFile = oFSO.OpenTextFile(sFileName) aFileArray = Split(oFile.ReadAll, CRLF) | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to read text file Hi Thankyou for the replay but dont work fine. CRLF = Chr(13) & Chr(10) sFileName = "c:\testes\teste.ual" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFile = oFSO.OpenTextFile(sFileName) aFileArray = Split(oFile.ReadAll, CRLF) Text1.Text = aFileArray(0) Text2.Text = UBound(aFileArray) The Text1 display "ÿþ2" The Text2 display "0" When I open "c:\testes\teste.ual" With NotePad" display exactli 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared 23-09-2008 14:23: Alarme de teste Medium Alarm 23-09-2008 14:23: Alarme de teste Automatically Acknowledged 23-09-2008 14:23: Alarme de teste Cleared "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:u1H259lHJHA.4408@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||
| Guest | Re: How to read text file "teste" <wq@xxxxxx> wrote in message news:newscache$4rmp7k$az$1@xxxxxx
file. Check the help file "script56.chm" (downloadable from the Microsoft site) for the full syntax of the OpenTextFile method and how to specify that the file should be opened in Unicode format. | ||||||||||||
My System Specs![]() | |||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: How to read text file On Sep 24, 11:36*am, "henrique" <qw...@xxxxxx> wrote:
with CreateObject("Scripting.FileSystemObject") .OpenTextFile("c:\list.txt", 1, true) aLines = Split(.ReadAll, vbNewline) End with for i = 0 to Ubound(aLines) aData(i) = Split(alines(i), " ") next Then address the data items with this syntax ... wsh.echo "For example:", aData(nLine)(nItem_on_the_line) This is pretty basic stuff. See the WSH documentation: WSH 5.6 documentation download (URL all one line) http://www.microsoft.com/downloads/d...displaylang=en and these samples" TechNet Script Center Sample Scripts (URL all one line) http://www.microsoft.com/downloads/d...a-b8814fe2da5a Tom Lavedas =========== http://members.cox.net/tglbatch/wsh/ | ||||||||||||
My System Specs![]() | |||||||||||||
| | #6 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to read text file Ok. But with this code and in VB Work fine FileNumber = FreeFile Open "c:\testes\teste.ual" For Input As #1 Do While Not EOF(FileNumber) Line Input #FileNumber, DF List1.AddItem DF Loop This VB code open in ASCII code!? H.S "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:ef1eB%23mHJHA.788@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #7 (permalink) | ||||||||||||
| Guest | Re: How to read text file "Henrique" <wq@xxxxxx> wrote in message news:newscache$qgqp7k$cb3$1@xxxxxx
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #8 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to read text file No! No! Not is the solution! This alternatif code work fine in VisualBasic, but dont work in VBScript! I´m findins un solution. Thanks "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:u5jxNcnHJHA.3668@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #9 (permalink) | ||||||||||||
| Guest | Re: How to read text file "Henrique" <wq@xxxxxx> wrote in message news:newscache$8xsp7k$7x4$1@xxxxxx
Enjoy! | ||||||||||||
My System Specs![]() | |||||||||||||
| | #10 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to read text file Hi! Ok. I have two solutions but dont work in my VBScript project. If the text file is in Unicode, the NotePad open it without problems? I´m using un SCADA software, with VBScript and Im testing the script in VB6. Sory my English Thanks "Pegasus (MVP)" <I.can@xxxxxx> escreveu na mensagem news:OLxAk6nHJHA.4760@xxxxxx
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
|
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Howto: Add lines of text from a specific point in a text file.. | Daz | VB Script | 13 | 06-24-2008 10:55 AM |
| How to read and write a text file? | Jirong Hu | VB Script | 1 | 06-14-2008 03:31 PM |
| Read a huge text file from bottom up | Hayato Iriumi | PowerShell | 4 | 04-25-2008 02:44 PM |
| How do I read a text file and sort text by fixed positions? | Cornelius | PowerShell | 5 | 07-20-2007 06:34 PM |
| Using ADO to read a text file | Marco Shaw | PowerShell | 3 | 11-09-2006 10:38 AM |