meisandy Posted June 17, 2010 Posted June 17, 2010 Hi, I can only keep this short and sweet (sorry) Basically I've got a string (for example) "This is my string" and I want to put a routine in a loop to view the string with one letter knocked of the end. So First loop: "This is my string" Second loop: "This is my strin" Third loop: "This is my stri" ...and so on until there is nothing left to veiw. Any idea's - Thanks P.S. When I say view I mean view! I DO NOT want the actually string to change! please
ajag Posted June 17, 2010 Posted June 17, 2010 (edited) Do you mean this? $myString = "This is my string" For $i = StringLen($myString) To 1 Step -1 MsgBox(0,"My String",StringLeft($myString,$i)) Next Edited June 17, 2010 by ajag Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1)
meisandy Posted June 17, 2010 Author Posted June 17, 2010 Errm...sorry may I have been a bit of an over reaction because while it works it is a little to simple for me. I need this sort of thing combined with a "Do" function. As the "To" is causing me problems. Thanks
zorphnog Posted June 17, 2010 Posted June 17, 2010 (edited) Why don't you post the code that is giving you trouble? A Do/Until loop is possible, but the For loop is really better for the situation.$sMyString = "This is a string" $i = StringLen($sMyString) Do MsgBox(0, "My String", StringLeft($sMyString, $i)) $i -= 1 Until $i = 0 Edited June 17, 2010 by zorphnog
meisandy Posted June 18, 2010 Author Posted June 18, 2010 Hi Zorphnog, Thanks Sorry, I didn't think I needed to post I code. Plus, I understand The for loop would be better, but I need something more than a numetical value to end the loop!
ajag Posted June 18, 2010 Posted June 18, 2010 Sorry, I didn't think I needed to post I code [...] Posting code always makes it much easier to help. The more I understand what you want, the more (and faster and better) I can help. A-Jay Rule #1: Always do a backup Rule #2: Always do a backup (backup of rule #1)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now