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. Split function

Split function

Scheduled Pinned Locked Moved Visual Basic
helpdata-structuresquestion
4 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.
  • L Offline
    L Offline
    leezardd
    wrote on last edited by
    #1

    Dim chrEachCharOut() As String = Split(txtAcctInXor.Text, "^") For Each chrSet In chrEachCharOut ‘do stuff here Next txtAcctInXor.Text contains 14^7^26^90 After the Split, chrEachCharOut has a length of 5. I was expecting 3 since the split returns a zero-based array containing the substrings. Why is the length 5? If I step thru the code I see 14, then 7, then 26, then 90, then I receive the following error -'System.InvalidCastException' occurred …”….Additional information: Cast from string "" to type 'Integer' is not valid. I only want the information between the ^ to be returned to me. Any ideas? All help appreciated!

    M 1 Reply Last reply
    0
    • L leezardd

      Dim chrEachCharOut() As String = Split(txtAcctInXor.Text, "^") For Each chrSet In chrEachCharOut ‘do stuff here Next txtAcctInXor.Text contains 14^7^26^90 After the Split, chrEachCharOut has a length of 5. I was expecting 3 since the split returns a zero-based array containing the substrings. Why is the length 5? If I step thru the code I see 14, then 7, then 26, then 90, then I receive the following error -'System.InvalidCastException' occurred …”….Additional information: Cast from string "" to type 'Integer' is not valid. I only want the information between the ^ to be returned to me. Any ideas? All help appreciated!

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi nug. Are you sure that txtAcctInXor.Text contains "14^7^26^90" and not "14^7^26^90^" with an extra "^" at the end?

      L 1 Reply Last reply
      0
      • M Mike Ellison

        Hi nug. Are you sure that txtAcctInXor.Text contains "14^7^26^90" and not "14^7^26^90^" with an extra "^" at the end?

        L Offline
        L Offline
        leezardd
        wrote on last edited by
        #3

        Sorry, there is an extra ^ at the end.

        M 1 Reply Last reply
        0
        • L leezardd

          Sorry, there is an extra ^ at the end.

          M Offline
          M Offline
          Mike Ellison
          wrote on last edited by
          #4

          It happens to the best of us ;)

          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