您好我正在尝试为我的调酒师标签编写vb脚本代码, 任何人都可以帮助我如何实现在字符串中填充空格,在字符串的末尾我需要添加〜至14个字符。
例如,如果我在text5中的数据有012 911 023 L
,那么首先我需要将其作为012911023L
,然后我需要添加〜,使得该text5中总共有14个字符。所以输出应该像012911023L~~~~
请注意,这不是一个C#或简单的脚本,就像vb我发现脚本在barteneder标签vb脚本中是非常不同的。
我的代码如下所示:
Dim sName
Dim fso
Dim fol
' get value from the text5
Set fol = Format.Objects("Text 1").Value
' go thru each files in the folder
For Each fil In fol.Files
' check if the file name contains tilde
If InStr(1, fil.Name, "~") <> 0 Then
' replace tilde with space
sName = Replace(fil.Name, "~", " ")
' rename the file
fil.Name = sName
End If
Next
对于我的上述脚本,我收到一个名为&#34的错误; OnAutoSelectedEvent (Line 7): Object required: '[string: "sample text"]'
答案 0 :(得分:0)
下面的代码会将我的字符串替换为上面的表单
Value = Replace(Value, " ", "")
Dim length
Dim Trim
length= Len(Value)
length= 14 -length
for d = 0 to length - 1
Value = Value & "~"
next