Results 1 to 5 of 5

Thread: String Manipulation

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    6

    String Manipulation

    I am using Visual Basic in Access for programming the Macros. I am using the access database to acquire data from lab instruments. I am using a bar code scanner and the output is as follows 103329. Now what I need to do is change it to 103320 (meaning I need to replace the last character with number 0). The last digit cud be any number and needs to be replaced with a 0. Please help

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: String Manipulation

    Moved to Office Development forum

    Hi ksushma, welcome to VBForums!

    This can be acheived by using a little string manipulation, using functions such as Left and Len. You haven't mentioned if the number is a fixed length, if it is you could use something like this:
    VB Code:
    1. [I]OutputText[/I] = Left([I]InputText[/I],5) & "0"
    However, if the length can vary you need to find the length too, using the Len function, eg:
    VB Code:
    1. [I]OutputText[/I] = Left([I]InputText[/I],Len([I]InputText[/I])) & "0"

  3. #3
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: String Manipulation

    Minor correction:

    Code:
    OutputText = Left(InputText,Len(InputText) -1) & "0"
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: String Manipulation

    Oops, well spotted!

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    6

    Re: String Manipulation

    Thank you very much it worked!!I will come back with more questions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width