Error on Form with VBA

R

RIck

I have an error on a webpage of mine since I added a function to save
the data in Proper Case-- but a smarter proper case. The page is not
displayed so I don't know where the error is or how to fix it
(obviously.) Here is the code:

Function MakeProper(var)

If Len(var) > 0 then

strV = var
bCaps = True

For i = 1 To Len(strV)
Select Case UCase(Mid(strV, i, 2))
Case " A"
bCaps = False
strV = Left(strV, i - 1) & UCase(Mid(strV, i, 2)) &
LCase(Mid(strV, i + 2))
i = i + 2
End Select

Select Case UCase(Mid(strV, i, 3))
Case " DL", " HR", " BB", " OK"
bCaps = False
strV = Left(strV, i - 1) & UCase(Mid(strV, i, 3)) &
LCase(Mid(strV, i + 3))
i = i + 3
End Select

Select Case UCase(Mid(strV, i, 4))
Case " MLB", " NFL", " RBI"
bCaps = False
strV = Left(strV, i - 1) & UCase(Mid(strV, i, 4)) &
LCase(Mid(strV, i + 4))
i = i + 4
End Select

If bCaps = True Then
strV = Left(strV, i - 1) & UCase(Mid(strV, i, 1)) &
LCase(Mid(strV, i + 1))
End If

If i <= Len(strV) Then
Select Case Asc(Mid(strV, i, 1))
Case 32, 45, 46, 47, 95
bCaps = True
Case Else
bCaps = False
End Select
End If
Next i

MakeProper= strV
else
MakeProper= var
end if
i = 0
End Function
 
R

RIck

I have an error on a webpage of mine since I added a function to save
the data in Proper Case-- but a smarter proper case. The page is not
displayed so I don't know where the error is or how to fix it
(obviously.) Here is the code:

I should also add that the code works in MS Access after some minor
modifications. That's where I originally created the code.
 
R

RIck

ok, thanks for you help everyone... ;)

The problem was the line "next i" I had to change it to "next". It's
possible there were other problems, but if there were I didn't catch
them as I fixed it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top