|
-
Feb 21st, 2003, 03:36 PM
#1
Thread Starter
PowerPoster
VB Snippet - Capatalize first Letter in all words in string
VB Code:
Function UpAllWords(ByVal TEXTIN As String) As String
Dim TextinS() As String
Dim Letter As String
Dim FinalWord As String
Dim MyItem As Integer
Dim c As Integer
TextinS = Split(TEXTIN, " ")
MyItem = UBound(TextinS)
For c = 0 To MyItem
Letter = Left(TextinS(c), 1)
Letter = UCase(Letter)
FinalWord = (Right(Letter, 1)) & Mid(TextinS(c), 2)
TextinS(c) = FinalWord
If UBound(TextinS) = c Then
UpAllWords = UpAllWords & TextinS(c)
Else
UpAllWords = UpAllWords & TextinS(c) & " "
End If
Next c
End Function
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Feb 21st, 2003, 04:31 PM
#2
StrConv("this is a string", vbProperCase)
Does the same thing I think.
-
Feb 21st, 2003, 05:16 PM
#3
Thread Starter
PowerPoster
Well
Never get tired of pissing on my parade, huh?
Yes , you are correct....
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Feb 22nd, 2003, 04:01 PM
#4
Fanatic Member
Originally posted by MartinLiss
StrConv("this is a string", vbProperCase)
Does the same thing I think.
There are some downside to STRConv.
MsgBox StrConv("C:\Documents and Settings\All Users", vbProperCase)
Would return something like this.
"C:\documents And Settings\all Users"
I think James method combined with strconv would be the idea choice. I altered your code a little bit James.
Code:
Option Explicit
Private Sub Form_Load()
MsgBox UpAllWords("C:\documents and settings\All users", "\")
End Sub
Function UpAllWords(ByVal TEXTIN As String, Optional ByVal strDelimiter As String = " ") As String
Dim TextinS() As String
Dim c As Integer
TextinS = Split(TEXTIN, strDelimiter)
For c = 0 To UBound(TextinS)
TextinS(c) = StrConv(TextinS(c), vbProperCase)
Next c
UpAllWords = Join(TextinS, strDelimiter)
End Function
Bird of Prey
Mr. Bald Eagle.
[img][/img]
-
Feb 27th, 2003, 04:44 AM
#5
This all sounds very familiar to me.
The code samples are getting repeated.
http://www.vbforums.com/showthread.p...hreadid=231506
-
Feb 27th, 2003, 07:50 PM
#6
Fanatic Member
Don't know where James got his original code but my code was trying to enhance his code. As for strConv, I learned years ago and I don't think that is knew to anyone.
The way you did it in the other thread still would not take care something like this
"C:\documents and settings\All users"
Last edited by Hawk; Feb 27th, 2003 at 07:58 PM.
Bird of Prey
Mr. Bald Eagle.
[img][/img]
-
Dec 15th, 2003, 05:41 PM
#7
Supreme User
I think this technique is know as "camel writing", because its like a camels hump. Starts high (Ucase) then goes low(Lcase).
Or was it called "donkey writing"?
-
Dec 15th, 2003, 05:46 PM
#8
Originally posted by Madboy
I think this technique is know as "camel writing", because its like a camels hump. Starts high (Ucase) then goes low(Lcase).
Or was it called "donkey writing"?
How does your post contribute to this thread?
-
Dec 15th, 2003, 05:50 PM
#9
Supreme User
It doesnt as such, but in one of my VB books it mentions this. And i though it would be useful to some, if they need to search such a thing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|