0

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):

  • "Example1"
  • "Example2"
  • "Example3"

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.

1
  • 2
    You need another loop to go through each string a character at a time and input a space. Commented Sep 10, 2020 at 23:04

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.