remove first characters of variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Henrootje

    remove first characters of variable

    Hello all,

    I have a problem that is alike others I have seen but I am not able to
    apply the solutions I saw using Trim, Left, Right and so on. That is
    why I ask here.

    What is the case?

    I have a variable 'OpenArgs' that can be filled with several values.
    They have in common that they all start with 'rpt' (eg;
    rptJaarOverzich t)
    Now I need OpenArgs to be frmJaarOverzich t.

    I was thinking along the lines:

    OpenArgs = rptJaarOverzich t
    OpenArgs2 = "frm" & <OpenArgs minus the first three characters/rpt>

    but what would be the right code to do this?

    Thanks for thinking!

  • Keith Wilby

    #2
    Re: remove first characters of variable

    "Henrootje" <HenroV@gmail.c om> wrote in message
    news:1151398050 .106255.117290@ p79g2000cwp.goo glegroups.com.. .[color=blue]
    > Hello all,
    >
    > I have a problem that is alike others I have seen but I am not able to
    > apply the solutions I saw using Trim, Left, Right and so on. That is
    > why I ask here.
    >
    > What is the case?
    >
    > I have a variable 'OpenArgs' that can be filled with several values.
    > They have in common that they all start with 'rpt' (eg;
    > rptJaarOverzich t)
    > Now I need OpenArgs to be frmJaarOverzich t.
    >
    > I was thinking along the lines:
    >
    > OpenArgs = rptJaarOverzich t
    > OpenArgs2 = "frm" & <OpenArgs minus the first three characters/rpt>
    >
    > but what would be the right code to do this?
    >
    > Thanks for thinking!
    >[/color]

    I think you need to set the OpenArgs property correctly in the first place,
    use "If" statements if you need to. Posting your code might help in finding
    a solution.

    Regards,
    Keith.



    Comment

    • Terry Kreft

      #3
      Re: remove first characters of variable



      OpenArgs = "rptJaarOverzic ht"
      OpenArgs2 = "frm" & Mid(OpenArgs, 4)


      --

      Terry Kreft


      "Henrootje" <HenroV@gmail.c om> wrote in message
      news:1151398050 .106255.117290@ p79g2000cwp.goo glegroups.com.. .[color=blue]
      > Hello all,
      >
      > I have a problem that is alike others I have seen but I am not able to
      > apply the solutions I saw using Trim, Left, Right and so on. That is
      > why I ask here.
      >
      > What is the case?
      >
      > I have a variable 'OpenArgs' that can be filled with several values.
      > They have in common that they all start with 'rpt' (eg;
      > rptJaarOverzich t)
      > Now I need OpenArgs to be frmJaarOverzich t.
      >
      > I was thinking along the lines:
      >
      > OpenArgs = rptJaarOverzich t
      > OpenArgs2 = "frm" & <OpenArgs minus the first three characters/rpt>
      >
      > but what would be the right code to do this?
      >
      > Thanks for thinking!
      >[/color]


      Comment

      • Henrootje

        #4
        Re: remove first characters of variable

        The solution Kerry!

        Thank you very much!

        Terry Kreft schreef:
        [color=blue]
        > OpenArgs = "rptJaarOverzic ht"
        > OpenArgs2 = "frm" & Mid(OpenArgs, 4)
        >
        >
        > --
        >
        > Terry Kreft
        >
        >
        > "Henrootje" <HenroV@gmail.c om> wrote in message
        > news:1151398050 .106255.117290@ p79g2000cwp.goo glegroups.com.. .[color=green]
        > > Hello all,
        > >
        > > I have a problem that is alike others I have seen but I am not able to
        > > apply the solutions I saw using Trim, Left, Right and so on. That is
        > > why I ask here.
        > >
        > > What is the case?
        > >
        > > I have a variable 'OpenArgs' that can be filled with several values.
        > > They have in common that they all start with 'rpt' (eg;
        > > rptJaarOverzich t)
        > > Now I need OpenArgs to be frmJaarOverzich t.
        > >
        > > I was thinking along the lines:
        > >
        > > OpenArgs = rptJaarOverzich t
        > > OpenArgs2 = "frm" & <OpenArgs minus the first three characters/rpt>
        > >
        > > but what would be the right code to do this?
        > >
        > > Thanks for thinking!
        > >[/color][/color]

        Comment

        • Lyle Fairfield

          #5
          Re: remove first characters of variable

          Henrootje wrote:[color=blue]
          > The solution Kerry![/color]

          I would have suggested:

          Replace("Kerry" , "K", "T")

          Comment

          • Lyle Fairfield

            #6
            Re: remove first characters of variable

            Lyle Fairfield wrote:[color=blue]
            > Henrootje wrote:[color=green]
            > > The solution Kerry![/color]
            >
            > I would have suggested:
            >
            > Replace("Kerry" , "K", "T")[/color]

            Probably

            Replace("Kerry" , "K", "T", , 1)

            would be better just in case "rpt" appears more than once in the string.

            Comment

            • Thelma Lubkin

              #7
              Re: remove first characters of variable

              Lyle Fairfield <lylefairfield@ aim.com> wrote:
              : Lyle Fairfield wrote:
              :> I would have suggested:
              :>
              :> Replace("Kerry" , "K", "T")

              : Probably

              : Replace("Kerry" , "K", "T", , 1)

              : would be better just in case "rpt" appears more than once in the string.

              Why? You're replacing k's, not t's.

              --ThelmaIsAbout

              Comment

              • Lyle Fairfield

                #8
                Re: remove first characters of variable


                Thelma Lubkin wrote:[color=blue]
                > Lyle Fairfield <lylefairfield@ aim.com> wrote:
                > : Lyle Fairfield wrote:
                > :> I would have suggested:
                > :>
                > :> Replace("Kerry" , "K", "T")
                >
                > : Probably
                >
                > : Replace("Kerry" , "K", "T", , 1)
                >
                > : would be better just in case "rpt" appears more than once in the string.
                >
                > Why? You're replacing k's, not t's.
                >
                > --ThelmaIsAbout[/color]

                The original poster was concerned about "rpt" I believe.

                Regardless, IMO, we should be careful about the number of Replaces we
                make. Consider Lyle. There's a big difference between replacing both
                L's with K's (a derogatory slang expression I am unlikely to use), and
                replacing just the first, (my evil twin).

                Replace has no judgement, so it may be a good idea for us to apply
                judgement before we use it.

                Comment

                • Thelma Lubkin

                  #9
                  Re: remove first characters of variable

                  Lyle Fairfield <lylefairfield@ aim.com> wrote:

                  : Thelma Lubkin wrote:
                  :> Lyle Fairfield <lylefairfield@ aim.com> wrote:
                  :> : Lyle Fairfield wrote:
                  :> :> I would have suggested:
                  :> :>
                  :> :> Replace("Kerry" , "K", "T")
                  :>
                  :> : Probably
                  :>
                  :> : Replace("Kerry" , "K", "T", , 1)
                  :>
                  :> : would be better just in case "rpt" appears more than once in the string.
                  :>
                  :> Why? You're replacing k's, not t's.
                  :>
                  :> --ThelmaIsAbout

                  : The original poster was concerned about "rpt" I believe.

                  Ah, I misinterpreted your context.

                  : Regardless, IMO, we should be careful about the number of Replaces we
                  : make. Consider Lyle. There's a big difference between replacing both
                  : L's with K's (a derogatory slang expression I am unlikely to use), and
                  : replacing just the first, (my evil twin).

                  : Replace has no judgement, so it may be a good idea for us to apply
                  : judgement before we use it.

                  I usually use something like Replace for massive replacement,
                  where I have no idea what the count might be, but in
                  trying to replace every occurrence of "tea" by "coffee"
                  I can lose my steak

                  You're right about OP's problem of course.

                  --thelma

                  Comment

                  • Terry Kreft

                    #10
                    Re: remove first characters of variable

                    Ha, insider info, I actually work with somone called Kerry and we are
                    forever getting each others phone calls so really I'm used to being mistaken
                    for Kerry.

                    --

                    Terry Kreft


                    "Lyle Fairfield" <lylefairfield@ aim.com> wrote in message
                    news:1151410285 .604807.69840@x 69g2000cwx.goog legroups.com...[color=blue]
                    > Henrootje wrote:[color=green]
                    > > The solution Kerry![/color]
                    >
                    > I would have suggested:
                    >
                    > Replace("Kerry" , "K", "T")
                    >[/color]


                    Comment

                    Working...