473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB textbox

how can i count the number of characters,special symbols and numbers given in an input testbox ?eg: if i give the input as i"know12,vb , the output should be as 7 characters,2 special symbols and 2 numbers.......
Sep 2 '07 #1
3 1917
Killer42
8,435 Expert 8TB
how can i count the number of characters ...
What version of VB are you using?

By the way, please don't post questions in the Articles area. I've moved this back to the Visual Basic Forum, where it belongs.
Sep 3 '07 #2
QVeen72
1,445 Expert 1GB
Hi,

Parse the Entire String, in a Loop, Keep a Variable for each.. and Count. I will Give you how to count Numbers , you can Modify the code for Chars/Special Chars etc..:

Expand|Select|Wrap|Line Numbers
  1. Dim TNum As Integer
  2. Dim i As Integer
  3. Dim TStr As String * 1 
  4. TNum = 0
  5. For i = 1 To Len(Text1.Text)
  6.    TStr = Mid(Text1.Text, i, 1)
  7.    If InStr("0123456789",TStr) > 0 Then
  8.         TNum = TNum + 1
  9.    End If
  10. Next
  11. MsgBox "Count of Numeric Chars : " & TNum
  12.  
REgards
Veena
Sep 3 '07 #3
Killer42
8,435 Expert 8TB
I'd suggest creating a function which returns the "type" of a given character. That way, you can do things like...
Expand|Select|Wrap|Line Numbers
  1. Dim I As Long ' <-- If later than VB6, use Integer.
  2. Dim strChar As String * 1 
  3. For I = 1 To Len(Text1.Text)
  4.   strChar = Mid(Text1.Text, I, 1)
  5.   Select Case CharType(strChar)
  6.     Case "A" ' Alpha
  7.       ' Increment your count of letters
  8.     Case "N" ' Numeric
  9.       ' Increment your count of numeric digits
  10.     Case "P" ' Punctuation
  11.       ' Increment your count of punctuation symbols
  12.     Case "S" ' Special character
  13.       ' Increment your count of 'special' symbols
  14.   End Select
  15. Next
Sep 4 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox...
4
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with...
0
by: Newasps | last post by:
Hi guys, I have a problem with UpdateCommand Event. In tihs event Ä°'m creating required controls to get that controls' values and also get them. But when I try to get updated values I'm getting the...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
3
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. ...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
1
by: Andy B | last post by:
I have this code: protected void EditEventsWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { //get the values from the DetailsView TextBox StartTime =...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.