Advertisement
ASP_Volume3 Coding Standards #49887

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.

AI

สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

ซอร์สโค้ด
original-source
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) & Text
End If
For 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 + 1
Next I
Loc = 1
For 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 I
Next J
Proper = Text
End Function
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine