1

我想将 Excel 中的数据行写入 XML 文件。但是,我需要在提交文件之前验证数据。我知道它WriteLine()有自己的行尾,但我需要将它添加到字符串中。所以我想做这样的事情:

strXML = "<BOM>" & {??} _
 & "<BOM_NBR>" & p_typBomValues.strParentPNbr & "</BOM_NBR>" & {??} _
 & "<DESC>" & p_typBomValues.strParentDesc & "</DESC>" & {??} _
 & "<ECO_NBR>" & p_typBomValues.strEcoNbr & "</ECO_NBR>" & {??} _
 & "<REV>" & p_typBomValues.strRevision & "</REV>"" & {??}
 .WriteLine(strXML)

...不是这个:

    .WriteLine ("<BOM>")
    .WriteLine ("<BOM_NBR>" & p_typBomValues.strParentPNbr & "</BOM_NBR>")
    .WriteLine ("<DESC>" & p_typBomValues.strParentDesc & "</DESC>")
    .WriteLine ("<ECO_NBR>" & p_typBomValues.strEcoNbr & "</ECO_NBR>")
    .WriteLine ("<REV>" & p_typBomValues.strRevision & "</REV>")

...其中 {??} 是行尾字符。我已经看到Chr(10) & Chr(13)提到作为一种选择,但没有确定的。

4

1 回答 1

1

FSO 关于它认为的读写换行的文档很少。但是您可能会安全地使用回车换行符 (vbCrLf) 或裸换行符 (vbLf)。在 Windows 上,前者是最安全的。

strXML = "<BOM>" & vbCrLf _
         & "<BOM_NBR>" & p_typBomValues.strParentPNbr & "</BOM_NBR>" & vbCrLf _
         & . . .
于 2015-10-09T19:11:27.473 回答