Converting the first character of a name to a capital?

  • Thread starter Guus van Waardenburg
  • Start date
G

Guus van Waardenburg

Good day all,

I have a problem of which I hop you can help me out with.

I have a userform to put in personal data of a client. The data my collegues
put in will be ending up in al letter. Now, in one ocasion Someone's name is
for example Guus van Waardenburg. When you write the name with the first name
'van' needs to be written in lower case, when you only write the last name,
'van' needs to be starting with a capital like this: 'Van Waardenburg', how
can I put this in my code?

My Code:

Selection.GoTo What:=wdGoToBookmark, Name:="Aanhef"
If TextBox4.Value = "" Then
If Not TextBox3.Value = "" Then
Selection.TypeText TextBox10 & " " & TextBox3 & " " & TextBox1 &
","
Else
Selection.TypeText TextBox10 & " " & TextBox1 & ","
End If
ElseIf Not TextBox17.Value = "" Then
Selection.TypeText TextBox10 & " " & TextBox17 & " " & TextBox4 & ","
Else
Selection.TypeText TextBox10 & " " & TextBox4 & ","
End If

Can someone help? (TextBox17 = van)
 
D

Dave Lett

Hi,

I'm not sure what your conditions are in context of your overall routine, so
maybe this little snippet will get you going in the right direction (then
set bCondition to False and run it again):

Dim sName As String
Dim bCondition As Boolean
sName = "van"

bCondition = True

If bCondition Then
sName = StrConv(sName, vbProperCase)
Else
sName = sName
End If

MsgBox sName

HTH,
Dave
 

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

Top