作成者カテゴリ返答の対象
公開
タルスメフィー
05/27/2003 10:00 AM
改行コードの置換について
文字列置換の関数を用意してみては


自分はEvaluateはなるべく使わないようにしているので以下のような
LotusScriptで文字列置換を行う為に自作した関数を利用しています。
ちなみに引数の指定は@関数のReplaceSubstringと同じです。

-----------------------------------------------------------------------------

Function ReplaceSubstring(word As String, frm As String, rep As String ) As String
'***********************************************
' 文字列置換関数
' 作成日 : 1999/09/18
' 修正日 : 2000/03/02
'***********************************************
Dim returnValue As String '戻り値
Dim temp As String '置換対象文字列の作業用
Dim wordL As String '置換処理用
Dim wordR As String '置換処理用
Dim pos As Integer '位置情報

'初期化
temp$ = word
returnValue$ = ""
If frm<>rep Then
pos% = Instr( temp$ , frm )
'置換文字列が無くなるまでループ
While pos%>0
wordL$ = Left( temp$ , pos%-1 )
wordR$ = Mid( temp$ , pos%+Len(frm) , Len(temp$))
temp$ = wordL$+rep+wordR$

'次の置換対象を検索
pos% = Instr( pos%+Len(rep) , temp$ , frm )
Wend
End If
returnValue$ = temp$
ReplaceSubstring = returnValue$

End Function

-----------------------------------------------------------------------------

これを踏まえて上で以下のように記述するとstrValue$変数内には改行と
タブを省いた文字列が格納されます。

-----------------------------------------------------------------------------
'フィールドの値を取得
strBody$ = doc.GetItemValue("No")(0)

'文字列から改行、タブを消去する
strValue$ = strBody$
strValue$ = ReplaceSubstring(strValue$, Chr(10), "") '改行(LF)
strValue$ = ReplaceSubstring(strValue$, Chr(13), "") '改行(CR)
strValue$ = ReplaceSubstring(strValue$, Chr(9), "") 'TAB

-----------------------------------------------------------------------------


[Previous Main Document]
改行コードの置換について (考える人)
. . UCHRやCHRでは? (けん)
. . . . 文字列置換の関数を用意してみては (タルスメフィー) * 現在地 *
. . Re:改行コードの置換について (NAG)
. . Re: 改行コードの置換について (HAL)
[Next Main Document]