# Proper case function! hi! iT is CoOl -> Hi! It is cool

To fix the input of the user. For example if the user inputs a bad case sentance it will make it normal:
what do yOu think? -> What do you think?
It checks for ./?/!. Have fun.

Original Author: Vitaly

### Returns

Proper case string

### Code

`Function Proper(Text As String)Dim FirstLetter%, I%, BadFormat%, J%, Loc%, Sta%Dim BreakL\$, BreakR\$'------------------------Text = LCase(Text)FirstLetter = Asc(Mid(Text, 1, 1))If FirstLetter >= 97 And FirstLetter <= 122 Then  Text = Right(Text, Len(Text) - 1)  Text = Chr(FirstLetter - 32) & TextEnd IfFor I = 1 To Len(Text) - 2  If Mid(Text, I, 1) = "." And Asc(Mid(Text, I + 2, 1)) >= 97 And Asc(Mid(Text, I + 2, 1)) <= 122 _   Then BadFormat = BadFormat + 1  If Mid(Text, I, 1) = "!" And Asc(Mid(Text, I + 2, 1)) >= 97 And Asc(Mid(Text, I + 2, 1)) <= 122 _   Then BadFormat = BadFormat + 1  If Mid(Text, I, 1) = "?" And Asc(Mid(Text, I + 2, 1)) >= 97 And Asc(Mid(Text, I + 2, 1)) <= 122 _   Then BadFormat = BadFormat + 1Next ILoc = 1For J = 1 To BadFormat  Sta = 200  If InStr(Loc, Text, ".") <> 0 Then Sta = InStr(Loc, Text, ".")  If InStr(Loc, Text, "?") < Sta And InStr(Loc, Text, "?") <> 0 _   Then Sta = InStr(Loc, Text, "?")  If InStr(Loc, Text, "!") < Sta And InStr(Loc, Text, "!") <> 0 _   Then Sta = InStr(Loc, Text, "!")  For I = Sta To Len(Text)    If Asc(Mid(Text, I, 1)) >= 97 And Asc(Mid(Text, I, 1)) <= 122 Then      Loc = I + 1      FirstLetter = Asc(Mid(Text, I, 1))      BreakL = Left(Text, I - 1)      BreakR = Right(Text, Len(Text) - I)      Text = BreakL & Chr(FirstLetter - 32) & BreakR      Exit For    End If  Next INext JProper = TextEnd Function`

Posted: 2002-06-01
By: ArchiveBot
Viewed: 143 times

Categories

Visual Basic 6

Attachments

No attachments for this post