Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing Speach Marks!!

Status
Not open for further replies.

lrmerc

Technical User
Nov 7, 2003
20
0
0
GB
I am new to this as you may find out by reading the following. Hopefully one of you guys have a quick solution.

I have a text file as follows which is constantly appended to :
"testing1"
"testing2"
"testing3"

I want to read the last line of this file into a Variable for use later. I have done this so far:

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso, ts, lastline
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso_OpenTextFile("text.txt", ForReading)
counter = 0
do while not ts.AtEndOfStream
counter = counter+1
lastline = ts.readline
loop

As you can see last line now has what i want but i need to strip off the speach marks so variable now has testing3..


Any help greatly recieved!!
 
If you simply want to remove all quotes then use (after loop):

Code:
lastline=Replace(lastline,Chr(34),"")

If you want to remove the first and last quote then use (after loop):

Code:
lastline = mid(lastline,2,len(lastline)-2)

HtH,

Rob

-Focus on the solution to the problem, not the obstacles in the way.-
 
Thanks for the info... I eventlually came up with this after reading a manual.... can you see any problem with me using this? It seems to work.......

lastline = Replace(lastline, """", "")

 
"""" is strictly the same as Chr(34).
 
Yep, they are the same. I just use Chr(34) as a personal preference (all those quotes confuse me [bugeyed])

Regards,

Rob

-Focus on the solution to the problem, not the obstacles in the way.-
 
What excatly does Chr(34) mean? This is the first script i have written... info is usefull!!! Thanks again
 
One more thing i am using this to force a password change on clients...... Is there anyway i can get a return code from this ie failure or success and pipe this to a file? I will keep working on it in the meantime....

Call User.SetPassword(password)

Thanks
 
"CHR" is a VB function that returns a character for the given ASCII code. Values are 0-255. 0 is a null character and typically 1-128 are "printable" characters while 129-255 can vary greatly from operating system to operating system (and from language to language within the same OS). ASCII is a character format that has been around for a while but is slowly being phased out in favor of Unicode ( which allows for pretty much any character in any language to be displayed. CHR's opposite is "ASC" which takes a character and gives you its character code. For instance, ASC("A") returns 65 while ASC("a") returns 97.

As to User.SetPassword: Instead of Call use the following...
Code:
Dim lngRetVal
lngRetVal = User.SetPassword(password)
If lngRetVal>0 then
 'some error occured
End If

In the very least says that is has a return value.

HtH

Rob

-Focus on the solution to the problem, not the obstacles in the way.-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top