フィールド内のいくつかの文字列を検索して計算を実行する必要があります。
たとえば、このフィールドは 100KSGD です。
K を取得し、100 の値を 1000 に掛ける必要があるため、100,000SGD が得られます。
次に、SGD を取得し、それを SGD から USD への外国為替レートで乗算する必要があります。それが私が得なければならない価値です。
Instr を使用して K を取得し、フィールドに他の文字列がなければ計算を実行できました。
そのための私のコードは次のとおりです。
If InStr(1 , OEMTEST_String$ , HasString_K$, 5) > 0 Then
Print "Searching for letter K in OEMTEST field..."
MsgBox("Letter K is found in OEMTEST field!")
Print "Converting OEMTEST field..."
'Replace All occurrences of K
tempPosition = InStr( 1, OEMTEST_String$, HasString_K$ )
If( ( Len( OEMTEST_String$ ) - Len( HasString_K$ ) ) + 1 = tempPosition ) Then
OEMnvar = Left( OEMTEST_String$, tempPosition - 1 )
MsgBox "The number value in OEMTEST field is " & OEMnvar
OEMnewvar = CDbl(OEMnvar) 'change nvar from string to double
OEMupdatedVar = CDbl(OEMnewvar * 1000) 'multiply the value by 1000
MsgBox "new value of OEMTEST is " & OEMupdatedvar 'check message box
'replace the value and save the document
Print "Saving converted value of OEMTEST field..."
Call note.ReplaceItemValue("OEMTEST", OEMupdatedVar)
Call note.Save(True, False)
End If
Else
Print "Letter K not found in OEMTEST field..."
End If
必要な値を取得するにはどうすればよいですか? ネストされた Instr を実行するにはどうすればよいですか?
どうもありがとうございます!