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. removing hyphens from a value

removing hyphens from a value

Scheduled Pinned Locked Moved Visual Basic
questiontutorial
3 Posts 3 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
    lxhan
    wrote on last edited by
    #1

    How do I remove a hyphen from a text? I'm retrieving the value from a textbox. The value, for example is 567-343, how do I get rid of the hyphen? The trim("-") function doesn't work on this value. Thanks!

    M T 2 Replies Last reply
    0
    • L lxhan

      How do I remove a hyphen from a text? I'm retrieving the value from a textbox. The value, for example is 567-343, how do I get rid of the hyphen? The trim("-") function doesn't work on this value. Thanks!

      M Offline
      M Offline
      Mandar Patankar
      wrote on last edited by
      #2

      Trim only removs the specific char from start and end of the string.In order to remove the char inbetween the string you can use split method or regular expression.I think in your case split method should be good enough.you can refer this code segment Dim FinalString as String Dim ActualString as String ="567-343" Dim splitString() as String=ActualString.split 'this returns an array of String Dim i as integer For i=0 to SplitString.length-1 if not(SplitString(i)="-") then FinalString=FinalString & SplitArray(i) end if next Hope this Helps Mandar Patankar Microsoft Certified professional Today Was not that Good..But I got tommorow.. :)

      1 Reply Last reply
      0
      • L lxhan

        How do I remove a hyphen from a text? I'm retrieving the value from a textbox. The value, for example is 567-343, how do I get rid of the hyphen? The trim("-") function doesn't work on this value. Thanks!

        T Offline
        T Offline
        tdciDoug
        wrote on last edited by
        #3

        Dim yourString as String = "567-343" yourString = Replace( yourString, "-", "" ) Have a wonderful evening Doug Wright Developer, TDCI

        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