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

S

Stefan Hoffmann

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 <--
 
F

Faz

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 <--
 
S

Stefan Hoffmann

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 <--
 
F

fredg

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.
 
F

Faz

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.
 
Top