What to use in VBScript to count

March 18, 2009 at 23:39:19
Specs: Windows XP, 1.5 GHz / 495 MB
What should I use in VBScript to count the # of times a letter appears in a string?
I've tried:

dim txt
txt="This is a beautiful day!"
document.write(Mid(txt,"i"))
document.write(Len(txt))

The code didn't even work...please help. Thanks.


See More: What to use in VBScript to count

Report •


#1
March 20, 2009 at 15:42:48
Hi, have you tried using the split and ubound functions? Maybe something like:

<%
Dim textstring, wipstring, numberoftimes
textString ="The brown fox jumped quickly over a fence"
wipstring = Split(textstring, "a")
numberoftimes = UBound(wipstring)
Response.write "The count is " & numberoftimes & " ."
%>


Report •

#2
March 20, 2009 at 23:02:27
Wow, you're awesome. Thanks! :)

Report •

Related Solutions


Ask Question