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. how to clear an array?

how to clear an array?

Scheduled Pinned Locked Moved Visual Basic
helpdata-structurestutorialquestion
2 Posts 2 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.
  • M Offline
    M Offline
    moomoooomoo
    wrote on last edited by
    #1

    good day everyone, i hope you can again help me with this: code : dim strVal() as string dim sVal as string = "a-b-c" - this can be changeable dim result as string = "" dim xCnt as integer strVal = split(sVal, "-") for xCnt = 0 to strVal -1 result & = strVal(xCnt) next first run : result = abc second run: result = abcabc <<-- this is the problem the code above runs smoothly, and no errors: but for the second runtime of the code above it does not clear the previous "strVal" value / results. how to clear the first result value of "strVal" ? thank you in advance, your help are highly appreciated. links/code are most highly appreciated thank you...:-D

    start a new beginning in every ending; thats what life for......

    C 1 Reply Last reply
    0
    • M moomoooomoo

      good day everyone, i hope you can again help me with this: code : dim strVal() as string dim sVal as string = "a-b-c" - this can be changeable dim result as string = "" dim xCnt as integer strVal = split(sVal, "-") for xCnt = 0 to strVal -1 result & = strVal(xCnt) next first run : result = abc second run: result = abcabc <<-- this is the problem the code above runs smoothly, and no errors: but for the second runtime of the code above it does not clear the previous "strVal" value / results. how to clear the first result value of "strVal" ? thank you in advance, your help are highly appreciated. links/code are most highly appreciated thank you...:-D

      start a new beginning in every ending; thats what life for......

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Start with result = string.Empty at the top of the loop. You can't clear an array, it is a fixed size object.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      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