私は、ファイルで抽出した値の1つにトリム(str)を使うたびにコンマ区切りのテキストファイルを読み込むスクリプトを用意しています...Vbscriptトリム関数
私のテキストファイル:
some string, anotherstring, onelaststring
some string, anotherstring, onelaststring
some string, anotherstring, onelaststring
some string, anotherstring, onelaststring
マイスクリプト:
Dim fso, myTxtFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set myTxtFile = fso.OpenTextFile("mytxt.txt")
Dim str, myTxtArr
txtContents myTxtFile.ReadAll
myTxtFile.close
myTxtArr = Split(txtContents, vbNewLine)
For each line in myTxtArr
tLine = Split(tLine, ",")
Trim(tLine(1))
If tLine(1) = "anotherstring" Then
MsgBox "match"
End If
Next
は私のスクリプトは、 "一致" に達することはありませんし、私はなぜわかりません。
範囲外のエラーが発生していますか? – STLDeveloper
エラーなし、ちょうどトリムしません – tarki
'trim(" some strings、anotherstring、onelaststring ")は決して' 'anotherstring" 'と等しくありません。おそらく、あなたは線を "、"に分割したいでしょうか? –