![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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 Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | reading last line of file hi guys, I have a text file which I need to read from a vbscript, but I should only get the last string. does anybody has an example that I could use to write such script ? further, the file has two empty strings at the bottom. which is the best method to deal with this ? should the script read the third line from the bottom, or is it simpler to get rid of these empty strings ? an example would be very, very appreciated! thanks in advance for any help. zz |
My System Specs![]() |
| | #2 (permalink) |
| | Re: reading last line of file <zerbie45@xxxxxx> wrote in message news:dfca51a7-b2f7-451d-a4e3-f4bebcb7ee7f@xxxxxx Quote: > hi guys, > > I have a text file which I need to read from a vbscript, but I should > only get the last string. does anybody has an example that I could use > to write such script ? > > further, the file has two empty strings at the bottom. which is the > best method to deal with this ? should the script read the third line > from the bottom, or is it simpler to get rid of these empty strings ? > an example would be very, very appreciated! work for you: '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Option Explicit Dim oFSO, oRegEx, sFileName, sText, oMatches Set oFSO = CreateObject("Scripting.FileSystemObject") Set oRegEx = CreateObject("VBScript.RegExp") oRegEx.Multiline = True oRegEx.Global = True sFileName = "C:\MyFile.txt" sText = oFSO.OpenTextFile(sFileName, 1).ReadAll oRegEx.Pattern = "^([^\s]+)$" Set oMatches = oRegEx.Execute(sText) MsgBox oMatches(oMatches.Count - 1) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Delete line after reading it on CSV | PowerShell | |||
| Reading SQL Table into Excel and calculating/inserting group line (with VBA)? | VB Script | |||
| Find hidden file, Reading from txt file | VB Script | |||
| Reading a text file and retaining line feeds | PowerShell | |||
| reading a big file line by line to be "out of memory" safe | PowerShell | |||