Ken Puls
01-07-2006, 10:54 AM
This is a test for Nate Oliver:
Public Function sCase(ByRef strIn As String) As String
Dim bArr() As Byte, i As Long, i2 As Long
If strIn = vbNullString Then Exit Function
Let bArr = strIn
Select Case bArr(0)
Case 97 To 122
bArr(0) = bArr(0) - 32
End Select
For i = 2 To UBound(bArr) Step 2
Select Case bArr(i)
Case 105
If Not i = UBound(bArr) - 1 Then
Select Case bArr(i + 2)
Case 32, 33, 39, 44, 46, 58, 59, 63, 148, 160
If bArr(i - 2) = 32 Then _
bArr(i) = bArr(i) - 32
End Select
ElseIf bArr(i - 2) = 32 Then _
bArr(i) = bArr(i) - 32
End If
Case 33, 46, 58, 63
For i2 = i + 2 To UBound(bArr) Step 2
Select Case bArr(i2)
Case 97 To 122
bArr(i2) = bArr(i2) - 32
i = i2: Exit For
End Select
Select Case bArr(i2)
Case 32, 33, 46, 63, 160
Case Else
i = i2: Exit For
End Select
Next
End Select
Next
sCase = bArr
End Function
Sub testTime()
Debug.Print sCase(LCase$("hello? erm, i'M only testing, eh. indeed, " & _
"i am inquisitve."))
Debug.Print sCase(LCase$("how old?! 22 Years."))
Debug.Print sCase(LCase$("how old?! twenty-two Years."))
Debug.Print sCase(LCase$("hmmmm.... wOrking?!?! sam i am. yes-no? " & _
"isn't i'm isn't."))
Debug.Print sCase(LCase$("THE DAY WAS SUNNY AND I WORE A HAT.PETER WAS THERE "))
Debug.Print sCase(LCase$("no WorRies, i'm ONLY testIng! yes-no?"))
Debug.Print sCase(LCase$("mY fRiend & i"))
Debug.Print sCase(LCase$("iiiiiiiiiiiiii"))
Debug.Print sCase(LCase$("***T. toast %T i @"))
Debug.Print sCase(LCase$("re: sentences."))
Debug.Print sCase("hello? thought i'd test this for David McRitchie. NOTHING.")
End Sub
Public Function sCase(ByRef strIn As String) As String
Dim bArr() As Byte, i As Long, i2 As Long
If strIn = vbNullString Then Exit Function
Let bArr = strIn
Select Case bArr(0)
Case 97 To 122
bArr(0) = bArr(0) - 32
End Select
For i = 2 To UBound(bArr) Step 2
Select Case bArr(i)
Case 105
If Not i = UBound(bArr) - 1 Then
Select Case bArr(i + 2)
Case 32, 33, 39, 44, 46, 58, 59, 63, 148, 160
If bArr(i - 2) = 32 Then _
bArr(i) = bArr(i) - 32
End Select
ElseIf bArr(i - 2) = 32 Then _
bArr(i) = bArr(i) - 32
End If
Case 33, 46, 58, 63
For i2 = i + 2 To UBound(bArr) Step 2
Select Case bArr(i2)
Case 97 To 122
bArr(i2) = bArr(i2) - 32
i = i2: Exit For
End Select
Select Case bArr(i2)
Case 32, 33, 46, 63, 160
Case Else
i = i2: Exit For
End Select
Next
End Select
Next
sCase = bArr
End Function
Sub testTime()
Debug.Print sCase(LCase$("hello? erm, i'M only testing, eh. indeed, " & _
"i am inquisitve."))
Debug.Print sCase(LCase$("how old?! 22 Years."))
Debug.Print sCase(LCase$("how old?! twenty-two Years."))
Debug.Print sCase(LCase$("hmmmm.... wOrking?!?! sam i am. yes-no? " & _
"isn't i'm isn't."))
Debug.Print sCase(LCase$("THE DAY WAS SUNNY AND I WORE A HAT.PETER WAS THERE "))
Debug.Print sCase(LCase$("no WorRies, i'm ONLY testIng! yes-no?"))
Debug.Print sCase(LCase$("mY fRiend & i"))
Debug.Print sCase(LCase$("iiiiiiiiiiiiii"))
Debug.Print sCase(LCase$("***T. toast %T i @"))
Debug.Print sCase(LCase$("re: sentences."))
Debug.Print sCase("hello? thought i'd test this for David McRitchie. NOTHING.")
End Sub