Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - How many Char(10) in var
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How many Char(10) in var

 Post Reply Post Reply
Author
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post Topic: How many Char(10) in var
    Posted: 19 July 2003 at 6:06pm
How can I get how many of a certain character there is on a variable......... ex. if i want to know how many A theres is on a var is there a simple function that will return that value..?

Thanks in advance,
FeRnAN
Back to Top
sprychun View Drop Down
Newbie
Newbie


Joined: 19 July 2003
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote sprychun Quote  Post ReplyReply Direct Link To This Post Posted: 19 July 2003 at 6:28pm

In VBScript you can do this:

Dim FindChr
Dim MyString
Dim CurChr
Dim Chrs
Dim A

FindChr = "B"
MyString = "ABCABCABCA"

Do

A = A + 1
CurChr = Mid(MyString, A, 1)
If CurChr = FindChr Then Chrs = Chrs + 1

Loop until A = len(MyString)

call MsgBox(Chrs)

Back to Top
sprychun View Drop Down
Newbie
Newbie


Joined: 19 July 2003
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote sprychun Quote  Post ReplyReply Direct Link To This Post Posted: 19 July 2003 at 6:30pm
If you need an explaination on this code please reply. Otherwise I hope it works for you.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 20 July 2003 at 10:17am

Function countchar(text, letter)

Dim length, currentletter

length = len(text)

For i = 1 to length

currentletter = mid(text, i, 1)

if currentletter = letter Then

countchar = countchar + 1

End if

Next

End Function

response.write countchar(variable, "A")



Edited by Mart
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.