Is there any way by which we can get each character from a string using VBScript? I had used the Mid
function but I just want to know if there are any other direct functions which when used returns each character starting from a string.
有什么方法可以使用VBScript从字符串中获取每个字符?我曾经使用过Mid函数,但我只是想知道是否有任何其他直接函数在使用时返回从字符串开始的每个字符。
5 个解决方案
#1
strString = "test"
For i=1 To Len(strString)
WScript.Echo Mid(strString,i,1)
Next
#2
AFAIK, Mid
is the only way to do this.
AFAIK,Mid是唯一的方法。
#3
a="abcd"
for i=1 to len(a)
msgbox right(left(a,i),1)
next
#4
Another way to do it, starting from 0 :
另一种方法,从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
#5
This code is useful to split Ucase and Lcase
此代码对于拆分Ucase和Lcase非常有用
Dim a
a="*"
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
strString = "test"
For i=1 To Len(strString)
WScript.Echo Mid(strString,i,1)
Next
#2
AFAIK, Mid
is the only way to do this.
AFAIK,Mid是唯一的方法。
#3
a="abcd"
for i=1 to len(a)
msgbox right(left(a,i),1)
next
#4
Another way to do it, starting from 0 :
另一种方法,从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
#5
This code is useful to split Ucase and Lcase
此代码对于拆分Ucase和Lcase非常有用
Dim a
a="*"
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