为每个字符添加一个空格而不用它们创建列 VBScript [英] Adding a space to every character without creating a column with them VBScript
问题描述
我正在尝试制作一个脚本,它只为字符添加空格,而不用它们创建一个列.这是我尝试过的代码:
I'm trying to make a script which only adds spaces to the characters and doesn't create a column with them. This is the code i tried:
<%
a=Split("Example1, Example2, Example3",",")
for each x in a
response.write(x & "<br />")
next
%>
问题是我有一个大文本,只会创建这样(这是正常输出):
And the problem is that i have a large text which only would create would be this (Which is the normal output):
- 示例 1"
- 示例2"
- 示例 3"
我希望它写的是这样的:"E x a m p l e 1 E x a m p l e 2 E x a m p l e 3"
And what i want it to write is this: "E x a m p l e 1 E x a m p l e 2 E x a m p l e 3"
我是这里编码的新手,所以我没有任何想法可做.任何帮助表示赞赏.
I'm new to code here so i don't have any ideas to do. Any help is appreciated.
推荐答案
正如 Lankymart 在评论中提到的,您可以循环遍历字符串的每个字符并添加空格.这是一个简单的函数:
As Lankymart mentioned in the comments, you can loop through each character of your string and add a space. Here's a simple function that does that:
Function SpaceText(p_sText)
Dim iCounter
Dim sSpacedText
sSpacedText = ""
For iCounter = 1 To Len(p_sText)
sSpacedText = sSpacedText & Mid(p_sText, iCounter, 1)
If iCounter < Len(p_sText) Then sSpacedText = sSpacedText & " "
Next
SpaceText = sSpacedText
End Function
您可以在现有循环中使用此函数:
You can use this function inside your existing loop:
response.write(SpaceText(x) & "<br />")
请注意,它不会在最后一个字母之后添加额外的空格,因此在连接数组的值时需要将其考虑在内.
Note that it doesn't add an extra space after the last letter so you need to factor that in when concatenating the values of your array.
这篇关于为每个字符添加一个空格而不用它们创建列 VBScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!