Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. build string from array

build string from array

Scheduled Pinned Locked Moved Visual Basic
questiondata-structures
8 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anoop Brijmohun
    wrote on last edited by
    #1

    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

    N CPalliniC 2 Replies Last reply
    0
    • A Anoop Brijmohun

      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

      N Offline
      N Offline
      Nilesh Hapse
      wrote on last edited by
      #2

      :confused::confused::confused:

      "Legacy code" often differs from its suggested alternative by actually working and scaling. —Bjarne Stroustrup

      A 1 Reply Last reply
      0
      • A Anoop Brijmohun

        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

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        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

        In testa che avete, signor di Ceprano?

        0 1 Reply Last reply
        0
        • CPalliniC CPallini

          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

          0 Offline
          0 Offline
          0x3c0
          wrote on last edited by
          #4

          CPallini wrote:

          BTW2: never heard about combinatorial explosion? [^]

          Thanks for that. I'd done some studying about factorials, and the nCr button on my calculator, but didn't know the proper name for it

          1 Reply Last reply
          0
          • N Nilesh Hapse

            :confused::confused::confused:

            "Legacy code" often differs from its suggested alternative by actually working and scaling. —Bjarne Stroustrup

            A Offline
            A Offline
            Anoop Brijmohun
            wrote on last edited by
            #5

            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

            CPalliniC R J 3 Replies Last reply
            0
            • A Anoop Brijmohun

              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

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #6

              Are you aware that computational time would increase as 26^N where N 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

              In testa che avete, signor di Ceprano?

              1 Reply Last reply
              0
              • A Anoop Brijmohun

                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

                R Offline
                R Offline
                riced
                wrote on last edited by
                #7

                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 building out one char at a time? If we knew that we might be able to suggest a way forward. :)

                Regards David R

                1 Reply Last reply
                0
                • A Anoop Brijmohun

                  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

                  J Offline
                  J Offline
                  Johan Hakkesteegt
                  wrote on last edited by
                  #8

                  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.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups