build string from array
-
hi all suppose i have an array like below dim Arr(26) as string Arr(1) = "A" Arr(2) = "B" Arr(3) = "C" ......... Arr(26) = "Z" i want an outut like the below A B C .. Z then AA BA CA .. ZA then AB BB CB .. ZB finaly AAA ZZB ZZC ... ZZZ and so on.. how can i do this.?:confused: thanks anoop
-
hi all suppose i have an array like below dim Arr(26) as string Arr(1) = "A" Arr(2) = "B" Arr(3) = "C" ......... Arr(26) = "Z" i want an outut like the below A B C .. Z then AA BA CA .. ZA then AB BB CB .. ZB finaly AAA ZZB ZZC ... ZZZ and so on.. how can i do this.?:confused: thanks anoop
:confused::confused::confused:
"Legacy code" often differs from its suggested alternative by actually working and scaling. —Bjarne Stroustrup
-
hi all suppose i have an array like below dim Arr(26) as string Arr(1) = "A" Arr(2) = "B" Arr(3) = "C" ......... Arr(26) = "Z" i want an outut like the below A B C .. Z then AA BA CA .. ZA then AB BB CB .. ZB finaly AAA ZZB ZZC ... ZZZ and so on.. how can i do this.?:confused: thanks anoop
Coding, I suppose. :rolleyes: BTW: recursion often helps... BTW2: never heard about combinatorial explosion? [^] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Thursday, April 16, 2009 6:14 AM
-
Coding, I suppose. :rolleyes: BTW: recursion often helps... BTW2: never heard about combinatorial explosion? [^] :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Thursday, April 16, 2009 6:14 AM
-
:confused::confused::confused:
"Legacy code" often differs from its suggested alternative by actually working and scaling. —Bjarne Stroustrup
well simply put. say i have a word "TEST" i want a string to build until it finds a match, namely "TEST" so in this case the loop should loop thru all the alphabets A-Z to do a check like below dim out as string dim arr() as string arr(1) ="A" arr(2) ="B" arr(26) ="Z" note that variable out is only a single character. for lp as integer =1 to 26 out = Arr(lp) IF out="TEST" then Msgbox("Found") end if next if a single character does not equal the word "TEST" then add a second character to out, like below.... for lp as integer =1 to 26 out = Arr(1) & Arr(lp) IF out="TEST" then Msgbox("Found") end if next this should repeat untill out = "TEST" hope this makes sense but dont know how to better explain the above thanks though
-
well simply put. say i have a word "TEST" i want a string to build until it finds a match, namely "TEST" so in this case the loop should loop thru all the alphabets A-Z to do a check like below dim out as string dim arr() as string arr(1) ="A" arr(2) ="B" arr(26) ="Z" note that variable out is only a single character. for lp as integer =1 to 26 out = Arr(lp) IF out="TEST" then Msgbox("Found") end if next if a single character does not equal the word "TEST" then add a second character to out, like below.... for lp as integer =1 to 26 out = Arr(1) & Arr(lp) IF out="TEST" then Msgbox("Found") end if next this should repeat untill out = "TEST" hope this makes sense but dont know how to better explain the above thanks though
Are you aware that computational time would increase as
26^N
whereN
is your test string lenght? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]modified on Thursday, April 16, 2009 4:37 PM
-
well simply put. say i have a word "TEST" i want a string to build until it finds a match, namely "TEST" so in this case the loop should loop thru all the alphabets A-Z to do a check like below dim out as string dim arr() as string arr(1) ="A" arr(2) ="B" arr(26) ="Z" note that variable out is only a single character. for lp as integer =1 to 26 out = Arr(lp) IF out="TEST" then Msgbox("Found") end if next if a single character does not equal the word "TEST" then add a second character to out, like below.... for lp as integer =1 to 26 out = Arr(1) & Arr(lp) IF out="TEST" then Msgbox("Found") end if next this should repeat untill out = "TEST" hope this makes sense but dont know how to better explain the above thanks though
Why not just set
out
to "TEST" since you are bound to find a match (eventually - within 26^N comparisons!):confused: What is the purpose behind doing it by buildingout
one char at a time? If we knew that we might be able to suggest a way forward. :)Regards David R
-
well simply put. say i have a word "TEST" i want a string to build until it finds a match, namely "TEST" so in this case the loop should loop thru all the alphabets A-Z to do a check like below dim out as string dim arr() as string arr(1) ="A" arr(2) ="B" arr(26) ="Z" note that variable out is only a single character. for lp as integer =1 to 26 out = Arr(lp) IF out="TEST" then Msgbox("Found") end if next if a single character does not equal the word "TEST" then add a second character to out, like below.... for lp as integer =1 to 26 out = Arr(1) & Arr(lp) IF out="TEST" then Msgbox("Found") end if next this should repeat untill out = "TEST" hope this makes sense but dont know how to better explain the above thanks though
What the others guys said. This sounds a lot like you are actually trying to accomplish something completely different from what you are describing here. What you are describing here, sounds to me like what you think is the solution to the actual problem. So please describe the actual problem to us.
My advice is free, and you may get what you paid for.