Click to See Complete Forum and Search --> : name function


Kyler
December 5th, 1999, 02:24 PM
I have a function that will return an inputted name in proper case as long as a middle initial is included. It fails if only a first name and last name is entered. Validation forces letters and spaces. Can anyone help with the needed code to display properly even if no middle initial is entered.

CStr(Text2.Text)

Ruth Glushkin
December 6th, 1999, 02:10 AM
Try something like that:

If Text2.Text <> "" Then MyText = MyText & CStr(Text2.Text)

In this condition you'll check, if your textbox is not empty.

Good Luck!

Allen Noakes
December 7th, 1999, 10:25 AM
Kyler,

Here is additional code for you to use.

Dim strIn As String
Dim astrIn() As String
Dim strOut As String
Dim I As Integer



strIn = "allen d echo f g noakes"
strIn = StrConv(strIn, vbProperCase)

astrIn = Split(strIn, " ")

For I = LBound(astrIn) To UBound(astrIn)

If Len(astrIn(I)) = 1 Then
astrIn(I) = astrIn(I) & "."
End If

strOut = strOut & " " & astrIn(I)
Next

Allen Noakes
VB Programmer/Analyst
Dames & Moore Group