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. Simple String Question

Simple String Question

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
4 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.
  • C Offline
    C Offline
    cwayman
    wrote on last edited by
    #1

    Hey I need to trim 4 characters off the right hand side of my string and am having a little trouble doing so. For example "Hello.doc" becomes "Hello" I could use split at "." but this wont stay constant if there is a "." in the filename itself Thanks for your time chris

    M 1 Reply Last reply
    0
    • C cwayman

      Hey I need to trim 4 characters off the right hand side of my string and am having a little trouble doing so. For example "Hello.doc" becomes "Hello" I could use split at "." but this wont stay constant if there is a "." in the filename itself Thanks for your time chris

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

      Hey, Chris. You could try:

      dim s1 as string = "Hello.doc";
      dim s2 as string = Left(s1, Len(s1) - 4)

      Or, if you're dealing with file/path names and want to extract portions of it (say just the filename, or just the extension, that sort of thing) have a look at the System.IO.Path class.

      L 1 Reply Last reply
      0
      • M Mike Ellison

        Hey, Chris. You could try:

        dim s1 as string = "Hello.doc";
        dim s2 as string = Left(s1, Len(s1) - 4)

        Or, if you're dealing with file/path names and want to extract portions of it (say just the filename, or just the extension, that sort of thing) have a look at the System.IO.Path class.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Hi, I might have the similar question too. I use an OpenFileDialog for user to select the file and they select TheFile.doc, How could I know that user select file extension with .doc? Can you help that? Because I want to check the 4 character from the right side.


        A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

        C 1 Reply Last reply
        0
        • L Lost User

          Hi, I might have the similar question too. I use an OpenFileDialog for user to select the file and they select TheFile.doc, How could I know that user select file extension with .doc? Can you help that? Because I want to check the 4 character from the right side.


          A thousand mile of journey, begin with the first step. APO-CEDC Save Children Norway-Cambodia Office

          C Offline
          C Offline
          cwayman
          wrote on last edited by
          #4

          Hey, Thanks Mike, i will try that. The man from .... you have to store the filename from teh openDialogBox and use the code that mike has said. Hope this helps Thanks Chris

          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