Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   Split String into individual characters (http://www.programmingforums.org/showthread.php?t=13402)

tAK Jun 20th, 2007 10:33 PM

Split String into individual characters
 
Hi,

I am trying to split a string into individual letters in VBScript.

str=text

i want to get back an array where:
a(0) = t
a(1) = e
a(2) = s
a(3) = t

there is:
a=split(str,"")
but it actually requires a character.. i have used other scripting languages where specifying "" means it will automatically split between every letter.. not helpful in this case.

The eventual script is to count how many UpperCase characters there are in a given string.

Cheers
tAK

So, i have this:
BUT, i have to enter input as:
t/E/s/t
instead of:
tEst

i want the latter.. any ideas please ?

:

<html>
<head>
<HTA:APPLICATION
    APPLICATIONNAME="Count UpperCase"
    SCROLL="yes"
    SINGLEINSTANCE="yes"
    WINDOWSTATE="Normal"
>
</head>
<body>
<script type="text/vbscript">

txtInput=InputBox("Enter a string:")
txtUpper=UCase(txtInput)
document.write("Your Input was: " & txtInput & "<br />")

arNormal=Split(txtInput,"/",-1,1)
arUpper=Split(txtUpper,"/",-1,1)

For i=0 to UBound(arNormal)
        If StrComp(arUpper(i),arNormal(i)) = 0 Then intUpperChars = intUpperChars + 1
        If StrComp(arUpper(i),arNormal(i)) = -1 Then intLowerChars = intLowerChars + 1
Next

document.write("Total Uppercase Characters = " & intUpperChars & "<br />")
document.write("Total Lowercase Characters = " & intLowerChars & "<br />")
</script>
</body>
</html>



All times are GMT -5. The time now is 10:11 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC