Web Hosting, Design, & Coding forum

General discussion

How to count # of times a letter appears in VBScript

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.

Discussion is locked
You are posting a reply to: How to count # of times a letter appears in VBScript
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: How to count # of times a letter appears in VBScript
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
Well not in VB but Java

In reply to: How to count # of times a letter appears in VBScript

Do some research on like...


string.length();


This might not be useful for you but you'll be using something similar.

.length checks for the characters in the String

Collapse -
May I ask where this requirement comes from.

In reply to: How to count # of times a letter appears in VBScript

Moreover, the requirement isn't very clear.
- Is T and t the same letter?
- Is a space a letter?
- Is an exclamation mark a letter?

Kees

Collapse -
I think he meant...

In reply to: May I ask where this requirement comes from.

A character.

Anything.

0 1 2 3 4 5 6 7 8 9

a to z

everything is considered a character in the string

Popular Forums

icon
Computer Newbies 10,686 discussions
icon
Computer Help 54,365 discussions
icon
Laptops 21,181 discussions
icon
Networking & Wireless 16,313 discussions
icon
Phones 17,137 discussions
icon
Security 31,287 discussions
icon
TVs & Home Theaters 22,101 discussions
icon
Windows 7 8,164 discussions
icon
Windows 10 2,657 discussions

SMART HOME

This one tip will help you sleep better tonight

A few seconds are all you need to get a better night's rest.