Hi,
Is there any way to change the words into "Sentence Case" as it can be done MS Office. Please let me know.
Regards,
Seema_S
Printable View
Hi,
Is there any way to change the words into "Sentence Case" as it can be done MS Office. Please let me know.
Regards,
Seema_S
you might want to look more into these three:
vbUppercase
vbLowercase
vbPropercase
VB Code:
Private Sub Form_Load() Debug.Print SentenceCase("this is a test. is it a test? yes it is! a test.") End Sub Private Function SentenceCase(ByVal sText As String) Dim b() As Byte, N As Long, bChange As Boolean b = sText bChange = True For N = 0 To UBound(b) Step 2 Select Case b(N) Case 33, 46, 58, 63 ' !.:? bChange = True Case 97 To 122 ' a-z If bChange Then b(N) = b(N) - 32: bChange = False Case 32 Case Else bChange = False End Select Next N SentenceCase = b End Function
Hi,Quote:
Originally Posted by bushmobile
Thanks. It is pretty nice. Now what I need is: when I enter a sentence in a textbox I will click on cmdSave button. So that the sentence entered should be saved in a Sentence Case format. Where should I call this function & what should be the line to call it?
Call SentenceCase ....> when I am using this line in cmdSave button's code, getting an error "argument not optional"
I have pasted the function code on the form. And calling it in cmdSave code.
Regards,
Seema_S
well, first off, I've missed something in my code - this function should be like this:well how you use the function is up to you. It accepts the text you want to change and outputs the changed version.e.g.:VB Code:
Private Function SentenceCase(ByVal sText As String) [B]As String[/B]VB Code:
Private Sub Command1_Click() Text1.Text = SentenceCase(Text1.Text) End Sub
Another way of doing that:
How to make Sentence Case
Thanks a lot for the help.Quote:
Originally Posted by bushmobile
Regards,
Seema_S