6 Replies - 627 Views - Last Post: 09 March 2012 - 02:38 PM Rate Topic: -----

#1 deverauxxi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 19-July 11

Counting some characters .

Posted 07 March 2012 - 05:31 AM

How can I count the number of special characters/ numbers that is inputted in a textbox.

For example:
079348625!@#$%^&*

Number Count: 9
Special Characters: 8

Thanks !
Is This A Good Question/Topic? 0
  • +

Replies To: Counting some characters .

#2 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Counting some characters .

Posted 07 March 2012 - 05:49 AM

I think its possible and easier by using Regular Expressions. Check the no. 16 in this article. Try it out.
Was This Post Helpful? 2
  • +
  • -

#3 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: Counting some characters .

Posted 07 March 2012 - 06:12 AM

To follow up on nK0de's excellent suggestion, have a look at this link on using regular expressions in vb6.

They may look a little awkward to begin with, but they are very powerful and worth taking the time to learn a little about them.
Was This Post Helpful? 2
  • +
  • -

#4 nK0de  Icon User is offline

  • Catch me As Exception
  • member icon

Reputation: 205
  • View blog
  • Posts: 823
  • Joined: 21-December 11

Re: Counting some characters .

Posted 07 March 2012 - 06:24 AM

:facepalm: oh shit! I opened this thread through the email notification and I didn't notice it was a VB6 question! I thought its VB.NET! sorry, my bad. and thanks maj3091 for the article on using RegEx in VB6. Haven't done that and didn't even know its possible in VB6. :)
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Counting some characters .

Posted 08 March 2012 - 04:01 PM

maj, it's not exactly the case that regular expressions aren't available except through a 3rd party solution, as the article you link suggests. Just set a (don't have VB6 here, can't quite remember name) reference to the VBScript regular expressions library.
Was This Post Helpful? 0
  • +
  • -

#6 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 300
  • View blog
  • Posts: 1,776
  • Joined: 26-March 09

Re: Counting some characters .

Posted 09 March 2012 - 01:01 AM

View PostBobRodes, on 08 March 2012 - 11:01 PM, said:

maj, it's not exactly the case that regular expressions aren't available except through a 3rd party solution, as the article you link suggests. Just set a (don't have VB6 here, can't quite remember name) reference to the VBScript regular expressions library.


To be honest Bob, I didn't realise the article said that, as I just quickly scouted through whilst on lunch at work, and it looked a good intro to RegEx functionality. I just assumed it referenced the inbuilt functionality.

Apologies if that caused any confusion OP.

This post has been edited by maj3091: 09 March 2012 - 01:01 AM

Was This Post Helpful? 0
  • +
  • -

#7 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: Counting some characters .

Posted 09 March 2012 - 02:38 PM

Kinda figured. :) they snuck that in at the end. And I would say that it is certainly a good intro to regex functionality.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1