Anybody here know Visual Studio....NET framework?

Search

New member
Joined
Sep 21, 2004
Messages
4,935
Tokens
Im trying to write a script that will delete the first and last line of a text file. All I can think of is the first line...anybody have a clue as to what I gotta do to delete the last AND first line...


PHP:
txtFilepath = "in.txt"
txtOut = "out.txt"
Dim objFSO, objTextFilein, objTextFileout
Dim sRead, sReadLine, sReadAll


Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFilein = objFSO.OpenTextFile(txtFilepath, ForReading)

On Error Resume Next
	 
sReadLine = objTextFilein.ReadLine

If Err.Number = 62 Then

objTextFilein.Close
Set txtFilepath = objFSO.GetFile("in.txt")
txtFilepath.Delete()

Else

Set objTextFileout = objFSO.CreateTextFile(txtOut, ForWriting)

Do While Not objTextFilein.AtEndOfStream
	sReadLine = objTextFilein.ReadLine
	objTextFileout.WriteLine(sReadLine)
loop

set sReadLine = Nothing
objTextFilein.Close
objTextFileout.Close

Set txtFilepath = objFSO.GetFile("in.txt")
txtFilepath.Delete()

Set txtOut = objFSO.GetFile("out.txt")
txtOut.Copy("in.txt")
txtOut.Delete()

End If
 

New member
Joined
Sep 21, 2004
Messages
4,935
Tokens
i got to a forum with 20,000+ members hoping that 1 of them is a web developer and is online

thanks for the link...but thats a php forum...i need VB

these vb forums take forever to get an answer
 

New member
Joined
Sep 21, 2004
Messages
4,935
Tokens
thats cuz i highlighted the code and clicked the php icon...just to make it easier to read

generally when you see
<$php

if (!tep_session_is_registered('customer_id')) {
$navigation->set_snapshot();
tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
}

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ACCOUNT);

$breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_ACCOUNT, '', 'SSL'));

$content = CONTENT_ACCOUNT;
$javascript = $content . '.js';

require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);

require(DIR_WS_INCLUDES . 'application_bottom.php');

?>


its the $ that makes it php

but really thanks for the link...i found some good stuff on that site that i can use in other developments :digit:
 

Rx Senior
Joined
Dec 10, 2002
Messages
8,483
Tokens
I have no seen VB in a while but here is an example of deleting a line. Just pass in the line number for first line and last line as a parameter.

I got the info from this link.
http://www.freevbcode.com/ShowCode.Asp?ID=2667

Dim oFSO As New FileSystemObject
Dim oFSTR As Scripting.TextStream
Dim ret As Long
Dim lCtr As Long
Dim sTemp As String, sLine As String
Dim bLineFound As Boolean

lCtr = 1
Do While Not oFSTR.AtEndOfStream
sLine = oFSTR.ReadLine
If lCtr <> LineNumber Then
sTemp = sTemp & sLine & vbCrLf
Else
bLineFound = True

End If
lCtr = lCtr + 1
Loop

oFSTR.Close
Set oFSTR = oFSO.CreateTextFile(fName, True)
oFSTR.Write sTemp

DeleteLine = bLineFound
End If
 

New member
Joined
Sep 21, 2004
Messages
4,935
Tokens
and you laughed at me for posting help in a gambling forum! HA back at ya...

what you posted did the trick...thanks bro!!! i owe ya - saved me hours worth of work :digit:
 

Forum statistics

Threads
1,106,768
Messages
13,438,832
Members
99,338
Latest member
chaicoca816
The RX is the sports betting industry's leading information portal for bonuses, picks, and sportsbook reviews. Find the best deals offered by a sportsbook in your state and browse our free picks section.FacebookTwitterInstagramContact Usforum@therx.com