正在为Strright寻找等效的VBA

问题描述 投票:0回答:1

正在寻找LotusScript的Strright的VBA等效项。该代码段是将错误消息连接到一个单元格中。

LotusScript Strright

'Meera's error message code
ReDim Preserve errormsg(i)
errormsg(i) = "Field Required"
IsError = True

...
errormsg(i) = "Invalid Date"
etc...

If IsError = True Then
   tmpMsg = ""
   For Each v In errormsg
       tmpMsg = tmpMsg + "," + v
   Next v
   Cells(Row, 8).Value = strright(tmpMsg, ",")      'LotusScript
End If
excel vba concatenation lotusscript
1个回答
0
投票

您可以使用Join()

If IsError = True Then
   Cells(Row, 8).Value = Join(errormsg, ",")
End If

或使用此模式:

If IsError = True Then
   Dim sep
   tmpMsg = ""
   For Each v In errormsg
       tmpMsg = tmpMsg + sep + v
       sep = ","
   Next v
   Cells(Row, 8).Value = tmpMsg
End If
© www.soinside.com 2019 - 2024. All rights reserved.