Problem w/snippet

1. Junior Member
Join Date
Dec 1969
Posts
26

## Problem w/snippet

Whats wrong w/the following?? It is supposed take the value of PageName (for example picture_gallery) and put in spaces for underscores and capitalize words so it would be Picture Gallery.<BR><BR>&#060;% <BR> PageName = Trim(PageName) <BR> arrWords = Split(PageName, "_", "-1", 1) <BR> <BR> For i=0 to in UBound(arrWords) <BR> strWord = arrWords(i) <BR> strWord = UCase(Left(strWord, 1) & Right(strWord, Len(strWord)-1) <BR> arrWords(i) = strWord <BR> Response.Write(strWord) & " " <BR> Next <BR>%&#062; <BR><BR>I tried to combine the following to get the above but it did not work:<BR><BR>For i=0 to in UBound(arrWords) <BR>strWord = arrWords(i) <BR>strWord = UCase(Left(strWord, 1) & Right(strWord, Len(strWord)-1) <BR>arrWords(i) = strWord <BR>Next <BR><BR>and this:<BR><BR>&#060;% <BR>PageName = Trim(PageName) <BR>arrWords = Split(PageName, "_", "-1", 1) <BR><BR>For Each strOneWord in arrWords <BR>Response.Write(strOneWord) & " " <BR>Next <BR>%&#062; <BR><BR><BR>Thanks. <BR>Andy <BR>andyt1286@yahoo.com

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Bogus code

For i=0 to in UBound(arrWords) <BR><BR>Huh??? "to in" ???<BR><BR>strWord = UCase(Left(strWord, 1) & Right(strWord, Len(strWord)-1) <BR><BR>Huh??? You are missing a right parenthesis there.<BR><BR>So that code won&#039;t even compile.<BR><BR>You know, if you are going to post in the ADVANCED forum, you need to learn to say more than "it didn&#039;t work". *HOW* didn&#039;t it work? What error did you get, if any? What output did you get (copy/paste from the screen!), if any? What were you expecting?<BR><BR>I see nothing obviously wrong with that code except the bogus "in" and the missing right paren. I would hope and assume that you had already discovered and fixed them? You could use MID a bit more efficiently than RIGHT. And you could use JOIN to make the output more efficient.<BR><BR>Thus:<BR><BR>&#060;%<BR>...<BR>a rrWords = Split(PageName, "_", "-1", 1) <BR><BR>For i=0 To UBound(arrWords) <BR>&nbsp; &nbsp; strWord = arrWords(i) <BR>&nbsp; &nbsp; arrWords(i) = UCase(Left(strWord, 1)) & Mid(strWord, 2) <BR>Next <BR>fixedName = Join( arrWords, " " )<BR>Response.Write fixedName<BR>...<BR>%&#062; <BR><BR>This really would have been a fine question for the general ASP forum, and you might have gotten more answers faster there. It doesn&#039;t really qualify as Advanced, you know, so why not go for the faster answers?<BR><BR><BR>

3. Junior Member
Join Date
Dec 1969
Posts
26

## Thank you

Thanks much for the support. I did not mean in any way to offend you with that message. I will think twice next time.<BR><BR>Cheers,<BR>Andy

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## Offend??? Not at all!

There was *NOTHING* offensive in what you wrote. And I certainly hope you weren&#039;t offended by my response. <BR><BR>It was a fine question, really. And one that deserved to be answered. It wasn&#039;t really advanced, so posting it in the Q&A forum would have been more appropriate. But what the heck...it was more advanced than some of the stuff that gets posted (and answered) here! At least you were *trying* to write a program, which is the point of these forums.<BR><BR>The only (real?) mistake you made was in not saying *how* the thing didn&#039;t work. When you don&#039;t tell us exactly what is wrong, we have to guess. In this case, I saw the two syntax errors. Were they really in your code? Or did they crop up when you typed the code into this forum? I couldn&#039;t tell. And nobody else would have been able to, either. I do hate making assumptions, because that just leads to wrong answers too often.<BR><BR>Keep posting! Just give more details next time, that&#039;s all.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•