Question

  • Creator
    Topic
  • #2146442

    Working with file names in VB

    Locked

    by jiminpa ·

    I have a file name I am working with in a particular piece of code I am attempting to write (I am not a programmer). I need to work with different pieces of this file name in different parts of my code.

    For example, let’s say I have a file call filename.c00. In one part of my code I need the part of the file name “filename.c” and in a different part of the code I need the part of the filename “00”.

    I am caputring the filename in a text box on a form. I have tried to use

    Right(textbox1.text, -4)

    but the comiler complains that I need a ‘)’ where the comma is. So I tried

    Right(textbox1.text – 4)

    but the compiler is treating the data as an interger but the data is actually alphanumerics. I tried Dimming a variable and setting it as a string and making the variable equal to right(textbox1.text – 4) but had the same result.

    My Google searches have been fruitless, likely I’m not using the right key words.

All Answers

  • Author
    Replies
    • #2460653

      Clarifications

      by jiminpa ·

      In reply to Working with file names in VB

      Clarifications

    • #2460501

      try something like this

      by lowlands ·

      In reply to Working with file names in VB

      looks like you are using the Right function wrong. It needs to be something like:
      strName = Left(Textbox1.Text,

      To get the amount of characters needed, you have to find two things, the length of your filename and the location of the “.”


      LengthofString = len(Textbox1.text)
      CommaLocation = instr(Textbox1.text, “.”)
      strExtension = Right(TextBox1.text, LengthofString – CommaLocation)
      StrName = Left(TextBox1.text, CommaLocation -1)


      if it still yaps about the textbox data being an integer, try assigning it to a variable first, strMyFilename = textbox1.text, then of course put strMyFileName in all the other lines.

Viewing 1 reply thread