how do i type sentences and have each word start with uppercase?

  • Thread starter Thread starter Guest
  • Start date Start date
hi,
how do i type sentences and have each word start with uppercase?
You may use

Function StrConv(String, Conversion As VbStrConv, [LocaleID As Long])
with Conversion := vbProperCase

But it's not aware of some special cases like O'Brain, will be convertet
to O'brain.



mfG
--> stefan <--
 
Hi Stefan, thank you. I am new to VB and i will really appreciate your help.
The name of my text box is "sentence" I did the following and it does not do
anything. Can you please write the exact code i should be using.

Private Sub String_BeforeUpdate(Cancel As Integer)
Dim sentence As String
sentence = StrConv(sentence, vbProperCase, 3)
End Sub

Thanks
Faz

Stefan Hoffmann said:
hi,
how do i type sentences and have each word start with uppercase?
You may use

Function StrConv(String, Conversion As VbStrConv, [LocaleID As Long])
with Conversion := vbProperCase

But it's not aware of some special cases like O'Brain, will be convertet
to O'brain.



mfG
--> stefan <--
 
hi,
Hi Stefan, thank you. I am new to VB and i will really appreciate your help.
The name of my text box is "sentence" I did the following and it does not do
anything. Can you please write the exact code i should be using.

Private Sub String_BeforeUpdate(Cancel As Integer)
Dim sentence As String
sentence = StrConv(sentence, vbProperCase, 3)
End Sub
Try

Private Sub String_BeforeUpdate(Cancel As Integer)

sentence.Value = StrConv(sentence.Value, vbProperCase, 3)

End Sub



mfG
--> stefan <--
 
Hi Stefan, thank you. I am new to VB and i will really appreciate your help.
The name of my text box is "sentence" I did the following and it does not do
anything. Can you please write the exact code i should be using.

Private Sub String_BeforeUpdate(Cancel As Integer)
Dim sentence As String
sentence = StrConv(sentence, vbProperCase, 3)
End Sub

Thanks
Faz

Stefan Hoffmann said:
hi,
how do i type sentences and have each word start with uppercase?
You may use

Function StrConv(String, Conversion As VbStrConv, [LocaleID As Long])
with Conversion := vbProperCase

But it's not aware of some special cases like O'Brain, will be convertet
to O'brain.

mfG
--> stefan <--

Use the control's AfterUpdate event, not the BeforeUpdate event.

Private Sub Sentence_AfterUpdate()
[Sentence] = StrConv([Sentence],3)
End Sub

Note: the above will capitalize the first letter of every word in the
field. It will also change each additional character in the word to
lower case, which in some instances may not be correct.
IBM will be changed to Ibm. McDonald to Mcdonald, O'Brien to O'brien
etc., and some names will be incorrectly capitalized: van der Meer
will become Van Der Meer, etc.
 
It works wonderfully, exactly as i wanted it to. Thank you both very much. I
really appreciate this help.

fredg said:
Hi Stefan, thank you. I am new to VB and i will really appreciate your help.
The name of my text box is "sentence" I did the following and it does not do
anything. Can you please write the exact code i should be using.

Private Sub String_BeforeUpdate(Cancel As Integer)
Dim sentence As String
sentence = StrConv(sentence, vbProperCase, 3)
End Sub

Thanks
Faz

Stefan Hoffmann said:
hi,

Faz wrote:
how do i type sentences and have each word start with uppercase?
You may use

Function StrConv(String, Conversion As VbStrConv, [LocaleID As Long])
with Conversion := vbProperCase

But it's not aware of some special cases like O'Brain, will be convertet
to O'brain.

mfG
--> stefan <--

Use the control's AfterUpdate event, not the BeforeUpdate event.

Private Sub Sentence_AfterUpdate()
[Sentence] = StrConv([Sentence],3)
End Sub

Note: the above will capitalize the first letter of every word in the
field. It will also change each additional character in the word to
lower case, which in some instances may not be correct.
IBM will be changed to Ibm. McDonald to Mcdonald, O'Brien to O'brien
etc., and some names will be incorrectly capitalized: van der Meer
will become Van Der Meer, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top