434,998 Members | 2,773 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Exception occured error

 P: n/a I'm getting an Exception occured error on line 4 (For i =1...) <% Function ProperCase(strIn) strOut = "" boolUp = True For i = 1 To Len(strIn) c = Mid(strIn, i, 1) if c = " " or c = "'" or c = "-" then strOut = strOut & c boolUp = True Else If boolUp Then tc = Ucase(c) Else tc = LCase(c) End If strOut = strOut & tc boolUp = False End If Next ProperCase = strOut End Function %> this function is put into an include file, and it uppercases a horse's name's first letter, and lowercases the rest, being called this way: response.write left(ProperCase(rs1("horsename")),14) What happens is when there are no more horse's names to be drawn from the database, that's when I get this Exception occured error thx for help Muench *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! Jul 19 '05 #1
3 Replies

 P: n/a Add a line to verify that the Len(strIn) > 0 J. Muenchbourg wrote: I'm getting an Exception occured error on line 4 (For i =1...) <% Function ProperCase(strIn) strOut = "" IF Len(strIn) > 0 then boolUp = True For i = 1 To Len(strIn) c = Mid(strIn, i, 1) if c = " " or c = "'" or c = "-" then strOut = strOut & c boolUp = True Else If boolUp Then tc = Ucase(c) Else tc = LCase(c) End If strOut = strOut & tc boolUp = False End If Next End If ProperCase = strOut End Function %> Bob Jul 19 '05 #2

 P: n/a > response.write left(ProperCase(rs1("horsename")),14) Did you try: response.write(rs1("horsename")) Is there a value there? What happens is when there are no more horse's names to be drawn from the database, that's when I get this Exception occured error Maybe you should be testing for EOF!??!? How are you looping through these horsenames? Maybe you could show more code, and we could show you how to fix it... Jul 19 '05 #3

 P: n/a I'm sure you've had a similar problem before. What happens if the horsename is null? If it is null then your line Len(strIn) is asking for the length of a null string... which is invalid. You need to test for null first. Function ProperCase strIn if isNull(strIn) then Exit Function OR Function ProperCase strIn strIn=strIn & "" 'That'll turn a null into an empty string. But be careful, an empty string may not work with the rest of your code. OR response.write left(ProperCase(rs1("horsename") & ""),14) ' Again, empty string "J. Muenchbourg" wrote in message news:eq**************@TK2MSFTNGP10.phx.gbl... I'm getting an Exception occured error on line 4 (For i =1...) <% Function ProperCase(strIn) strOut = "" boolUp = True For i = 1 To Len(strIn) c = Mid(strIn, i, 1) if c = " " or c = "'" or c = "-" then strOut = strOut & c boolUp = True Else If boolUp Then tc = Ucase(c) Else tc = LCase(c) End If strOut = strOut & tc boolUp = False End If Next ProperCase = strOut End Function %> this function is put into an include file, and it uppercases a horse's name's first letter, and lowercases the rest, being called this way: response.write left(ProperCase(rs1("horsename")),14) What happens is when there are no more horse's names to be drawn from the database, that's when I get this Exception occured error thx for help Muench *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion. 