VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Count the number of occurences of a character in a text box control.

by Brandon (46 Submissions)
Category: String Manipulation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 16th August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Count the number of occurences of a character in a text box control.

Rate Count the number of occurences of a character in a text box control.



'put a text box and a command button on your form.
'count the number of v's in textbox
Dim i As Integer
Dim x As Integer
Dim count As Integer
Dim char_length As Integer
Dim char As String
x = Len(Text1)
For i = 1 To Len(Text1)
    char = Mid(Text1, x, 1)
    If char = "v" Then
        count = count + 1
    End If
    x = x - 1
Next
MsgBox "There are a total of " & count & " v's", vbInformation
End Sub

Download this snippet    Add to My Saved Code

Count the number of occurences of a character in a text box control. Comments

No comments have been posted about Count the number of occurences of a character in a text box control.. Why not be the first to post a comment about Count the number of occurences of a character in a text box control..

Post your comment

Subject:
Message:
0/1000 characters