DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

1. Senior Member
Join Date
Aug 2004
Posts
43,023

## Please please save my life and help

[Originally posted by fun lvn crmnl]

Hi, this is a bit cheeky but what it is is that I'm at night college right now doin a visual basic test and everythin's gone straight out of my head and I don't have any help sheets or anythin and I was wonderin if any of you lot would possibly be able to save my life and give me a hand? If you do I would be MASSIVELY gratefull. Anyway first off if you are kind enough to help me (please?) I have one text box and two labels. The first label has to count how many vowels there is in the text box and display it. the second label has to count how many lines in the text box there are. I also have to have it so it will automaticly convert the vowles into cappitals. Any help would be MASSIVELY appreciated. Thanks if you can help in anyway.

2. Senior Member
Join Date
Aug 2004
Posts
43,023

## Re:Please please save my life and help

[Originally posted by Dustin]

You meant Listbox, not textbox, rite?
Here you go:
Q2. Label2.caption = Listbox1.ListCount

3. Senior Member
Join Date
Aug 2004
Posts
43,023

## Re:Re:Please please save my life and help

[Originally posted by fun lvn crmnl]

No mate a text box it is, I have to count the lines of text, I think I've got that one sorted though. Cheers for helpin anyway you're a star :)

4. Senior Member
Join Date
Aug 2004
Posts
43,023

## Re:Re:Re:Please please save my life and help

[Originally posted by Dustin]

Ok, Label1.caption = Text1.Height then

5. Senior Member
Join Date
Aug 2004
Posts
43,023

## Re:Please please save my life and help

[Originally posted by neophile]

Option Explicit

Private Sub Text1_Change()
ÿ ÿ Dim lCount As Long
ÿ ÿ Dim i As Integer
ÿ ÿ For i = 1 To 5
ÿ ÿ ÿ ÿ lCount = lCount + FindCount(Text1.Text, Mid("AEIOU", i, 1))
ÿ ÿ Next
ÿ ÿ Label1.Caption = CStr(lCount) & " vowel(s)"
ÿ ÿ Label2.Caption = CStr(FindCount(Text1.Text, vbCrLf) + 1) & " line(s)"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
ÿ ÿ Select Case KeyAscii
ÿ ÿ ÿ ÿ Case 97, 101, 105, 111, 117
ÿ ÿ ÿ ÿ ÿ ÿ KeyAscii = KeyAscii - 32
ÿ ÿ ÿ ÿ ÿ ÿ Debug.Print KeyAscii
ÿ ÿ End Select
End Sub

Private Function FindCount(ByVal Text As String, ByVal Find As String) As Long
ÿ ÿ Dim lPos As Long
ÿ ÿ lPos = InStr(1, Text, Find, vbTextCompare)
ÿ ÿ While lPos > 0
ÿ ÿ ÿ ÿ FindCount = FindCount + 1
ÿ ÿ ÿ ÿ lPos = InStr(lPos + 1, Text, Find, vbTextCompare)
ÿ ÿ Wend
End Function

... I hope this helps ;)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 FAQ Latest Articles Java .NET XML Database Enterprise
 Questions? Contact us. C++ Web Development Wireless Latest Tips Open Source