réponse Andrew est pas correct. LTrim, RTrim et Trim suppriment uniquement les espaces, pas les onglets.
J'ai reformaté votre code et ajouté une fonction pour supprimer les caractères de début ou de fin.
filename="test.txt"
set fso = createobject("scripting.filesystemobject")
set f = fso.opentextfile(filename)
do while not f.AtEndOfStream
s = TrimChars(f.readline, " " + vbTab)
wscript.echo "|" & s & "|"
loop
f.close
set f = nothing
set fso = nothing
''---
function TrimChars(s, sChars)
dim n, nLen, nStart
nLen = Len(s)
if nLen = 0 then
TrimChars = s
exit function
end if
''- skip leading chars
n = 1
do while (n <= nLen) And (InStr(sChars, Mid(s, n, 1)) > 0)
n = n + 1
loop
nStart = n
''- skip trailing chars
n = nLen
do while (n > nStart) And (InStr(sChars, Mid(s, n, 1)) > 0)
n = n - 1
loop
''- return remaining chars
nLen = n - nStart + 1
if (nLen > 0) and (nStart <= len(s)) then
TrimChars = Mid(s, nStart, nLen)
else
TrimChars = ""
end if
end function
Grande fonction, merci! –