Announcement

Collapse
No announcement yet.

insert spaces in string

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    insert spaces in string

    Need to convert a String to have spaces. "12345" to "1 2 3 4 5".

    Thanks.

    #2
    <pre class="ip-ubbcode-code-pre">

    function insertSpaces(sText)
    lengthOfsText = len(sText)
    sNewString = ""
    for i = 1 to lengthOfsText - 1
    sNewString = sNewString & mid(sText,i,1) & " "
    next
    insertSpaces = sNewStirng & right(sText,1)
    end function

    sub main()
    hs.speak insertSpaces("1234")
    end sub


    </pre>

    Comment


      #3
      Thanks for the code.

      before you posted your message I got it to work this way.

      <pre class="ip-ubbcode-code-pre">
      convertspace = "12345"

      Dim Tmp, i
      For i = 1 to Len( convertspace )
      Tmp = Tmp & Mid( convertspace, i, 1 ) & " "
      Next

      hs.speak Tmp

      </pre>

      Comment


        #4
        Michael

        For some reason when I use your code it only speaks the last Number.

        hs.speak insertSpaces("12345") only speaks 5.

        Here is what I finally ended up using.

        <pre class="ip-ubbcode-code-pre">
        Function spaces(string)
        Dim Tmp, i
        For i = 1 to Len(string)
        Tmp = Tmp & Mid(string, i, 1 ) & " "
        Next
        spaces = Tmp
        End Function

        sub main()
        hs.speak spaces("12345")
        end sub
        </pre>

        Comment


          #5
          There is a typo in Michael's code. After the For loop the statement refers to "sNewStirng" instead of "sNewString". If you fix that it will work.

          Bill

          Comment

          Working...
          X