Solved Add space to string VBScript

f04959c

New Member
Hello,

I have tried to add space to a particula string in VBScript, but somethings doesn't works.

I have write the code in VBScript that work

Code:
Dim iText, oText

iText = "GoofyMickeyMousePlutoDonaldDuck"
MsgBox iText
oText = Add_Spaces(iText)
MsgBox oText



Function Add_Spaces(sText)
   Dim CharNum, CharCode
   Dim FixedText

   FixedText = Left(sText, 1)

   For CharNum = 2 To Len(sText)
      CharCode = Asc(Mid(sText, CharNum, 1))
      If CharCode >= 65 And CharCode <= 90 Then
         FixedText = FixedText & " " & Mid(sText, CharNum, 1)
      Else
         FixedText = FixedText & Mid(sText, CharNum, 1)
      End If
   Next

   Add_Spaces = FixedText
End Function

When I try to move it in BLueprism somethings doen't work and return me the following message

Internal : Unexpected error Ambiguous match found.

View attachment Initialise.JPG

View attachment Add_Space.JPG
 

f04959c

New Member
Fixed changed in the following approch

Code:
Protected Function Add_Spaces(sText as string) as string
   Dim CharNum as integer
   Dim CharCode as integer
   Dim FixedText as string

   FixedText = Left(sText, 1)

   For CharNum = 2 To Len(sText)
      CharCode = Asc(Mid(sText, CharNum, 1))
      If CharCode >= 65 And CharCode <= 90 Then
         FixedText = FixedText & " " & Mid(sText, CharNum, 1)
      Else
         FixedText = FixedText & Mid(sText, CharNum, 1)
      End If
   Next

   return FixedText
End Function
 
Top