#1
  1. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jan 2004
    Location
    Budapest
    Posts
    1,703
    Rep Power
    67

    Remove last character from a string


    How can I get a string from this

    22, 32, 43, 23, 44,

    to this

    22, 32, 43, 23, 44

    I want to cut the last coma
    Today the world, tomorrow the universe...
  2. #2
  3. i don't do negative rep
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2006
    Posts
    760
    Rep Power
    706
    something like Left(str,Len(str)-1) ?

    Comments on this post

    • palagrim agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2008
    Posts
    1
    Rep Power
    0
    If you want to erase / delete last character in the last line of a text file, you can use this script:

    Code:
    Const ForReading = 1
    Const ForWriting = 2
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    
    Set objFile = objFSO.OpenTextFile("Text_File.txt", ForReading)
    strFile = objFile.ReadAll
    objFile.Close
    
    intLength = Len(strFile)
    strEnd = Right(strFile, 2)
    
    strFile = Left(strFile, intLength - 1)
    Set objFile = objFSO.OpenTextFile("Text_File.txt", ForWriting)
    objFile.Write strFile
    objFile.Close
    Don't forget to replace the two "Text_File.txt" parts of this script with the correct name of the file you want to edit and also these two files have to be in the same directory otherwise you must replace the two "Text_File.txt" parts of this script with the full path of the text file you want to edit.

    You use the above script by pasting it to empty text file, then renaming the file's extension to ".vbs". You run it by applying cmd command :
    Code:
    cscript Your_Script_File.vbs
    Many other VB scripts can be found here:
    http://www.microsoft.com/technet/scriptcenter/resources/

IMN logo majestic logo threadwatch logo seochat tools logo