Get every character in a string using VBScript

Is there a way by which we can get each character from a string using VBScript? I used a function Mid, but I just want to know if there are other direct functions that, when used, return every character starting with a string.

+5
source share
5 answers
strString = "test"
For i=1 To Len(strString)
    WScript.Echo Mid(strString,i,1)
Next 
+22
source

AFAIK, Midis the only way to do this.

+2
source
a="abcd"

for i=1 to len(a)

msgbox right(left(a,i),1)

next
+2
source

Another way to do this, starting at 0:

str = "hola che"
x=Len(str)    
text = ""
For i=0 to x-1  'x-1 is because it exceeds the actual length    
    text= text & Mid(str,i+1,1)    
Next    
msgbox text
+2
source

This code is useful for distinguishing between Ucase and Lcase.

Dim a
a="StAcKoVeRfLoW"

for i=o to len(a)-1
if mid(a,i+1,1)=ucase(mid(a,i+1,1)) then
  b=mid(a,i+1,1)
msgbox b
end if
next
-1
source

All Articles