
Automatic Capital Letter for 1st Letter???
Try this:
Function First_Cap(work, ParamArray tbl()) As String
'----------------------------------------------------------------
'Purpose capitalises the first letter in each word in a string
' and allows for character table to allow for
' e.g. mycompany(australia) to capitalise "a"
'23/09/98
'Modified by:
'Date:
'Details:
'----------------------------------------------------------------
Dim i As Integer
Dim x As Integer
Dim char As String
Dim txt As String
Dim temp As String
Dim boolChar As Boolean
Dim boolHasArray As Boolean
'--------------------------
On Error Resume Next
txt = Trim(work) 'get rid of outer spaces
txt = LCase(txt) 'set all to lower case
boolHasArray = (UBound(tbl) <> -1)
First_Cap = "" 'default
If (txt = "") Then
Exit Function
Else
For i = 1 To Len(txt)
char = Asc(Mid$(txt, i, 1))
'--------------------------------
'if first char or flag set from
'previous char
'--------------------------------
If (i = 1 Or boolChar) Then
temp = temp & UCase$(Chr$(char))
boolChar = False
Else
temp = temp & Chr$(char)
End If
'--------------------------------
'check char for chr(32) or chars
'in paramarray
'--------------------------------
If (char = 32) Then
boolChar = True 'flag for next iteration
ElseIf boolHasArray Then
For x = LBound(tbl) To UBound(tbl)
If (char = tbl(x)) Then
boolChar = True 'flag for next iteration
Exit For
End If
Next
End If
Next
End If
First_Cap = temp
End Function
Quote:
> Try using the masked edit control, you can make it so that all letters are
cap
> or all are lower, but i would imagine you can mix the two i know the
commands
> are somthing like slashes or somthing sorry i am so vague, but look in the
MSDN
> i know its {*filter*}but it will tell you what formatting to use.
> >This doesn't work if there is already some text in the box which you've
> >highlighted prior to overwriting it with the new text. You need to omit
the
> >If Then clause.
> >>Private Sub Text1_Change()
> >> On Error Resume Next
> >> If Text1.Text <> "" Then
> >> Text1.Text = UCase(Left(Text1.Text, 1)) & Right(Text1,
> >>Len(Text1.Text) - 1)
> >> Text1.SelStart = Len(Text1.Text)
> >> End If
> >>End Sub
> >>--
> >>Clint LaFever
> >> http://www.*-*-*.com/
> >> http://www.*-*-*.com/ (personal)
> >>(Home of the Code Depot Add-In)
> >>> Hi i was wondering how i would make the first letter that i input into
a
> >>> text box turn automatically into a Capital Letter???
> >>> Thanks in advance
> "The illiterate of the 21st century will not be those who cannot read and
> write, but those who cannot learn, unlearn and relearn."--Alvin Toffer