Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: MOD Implementation
 Hopefully a Little Help with my TitleCase Function

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!
Before posting, make sure you have read this topic!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
bobby131313 Posted - 24 May 2020 : 20:07:50

So I scrounged this function up many, many years ago and it works great....


Function TitleCase(stValue)
iPos = 1
Do While InStr(iPos, stValue, " ", 1) <> 0
iSpace = InStr(iPos, stValue, " ", 1)
sTemp = sTemp & UCase(Mid(stValue, iPos, 1))
sTemp = sTemp & LCase(Mid(stValue, iPos + 1, iSpace - iPos))
iPos = iSpace + 1
Loop

sTemp = sTemp & UCase(Mid(stValue, iPos, 1))
sTemp = sTemp & LCase(Mid(stValue, iPos + 1))

TitleCase = sTemp
End Function


This capitalizes every letter after a space.

I would like it to also capitalize letters after a dash. I played with it for several hours yesterday but obviously functions are not my strong suit.
3   L A T E S T    R E P L I E S    (Newest First)
Carefree Posted - 28 May 2023 : 05:02:24
Antique topic, but this would work:


Function TitleCase(fString)
iPos = 1
Do While ((InStr(iPos, fString, " ", 1) <> 0) Or (InStr(iPos, fString, "-", 1) <> 0))
If InStr(iPos, fString, " ", 1) Then
iSpace = InStr(iPos, fString, " ", 1)
ElseIf InStr(iPos, fString, "-", 1) Then
iSpace = InStr(iPos, fString, "-", 1)
End If
sTemp = sTemp & UCase(Mid(fString, iPos, 1))
sTemp = sTemp & LCase(Mid(fString, iPos + 1, iSpace - iPos))
iPos = iSpace + 1
Loop
sTemp = sTemp & UCase(Mid(fString, iPos, 1))
sTemp = sTemp & LCase(Mid(fString, iPos + 1))
TitleCase = sTemp
End Function
bobby131313 Posted - 26 May 2020 : 16:26:58
Thanks Hu, I will play with it today.
HuwR Posted - 26 May 2020 : 07:33:10
You will probably need to do the replacement twice, you could try changing your function so that it also accepts a variable that it is to use as the separator, you can then call the same function twice by passing it a space and then a dash

so, declare the function like Function TitleCase(stValue, stSeparator) and the do while would change to Do While InStr(iPos, stValue, stSeparator, 1) <> 0 and the same for the iSpace = InStr(iPos, stValue, " ", 1) change to iSpace = InStr(iPos, stValue, stSeparator, 1)

Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000 Version 3.4.07