Right$ doesn't work

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bo Wisén

    Right$ doesn't work

    Hi,

    A project in VB6 recently worked without any problems but now it's
    complaining when I try to use 'Right$'. In immediate mode, when I'm typing
    'print left$("123456", 2)' I get the correct result '12'. When I type 'print
    right$("123456" ,2) I expect the result '56' but all I get is an error 'type
    declaration does not match declared data type'. And I can't find that I have
    tried to declare 'right'. Can anyone explain what can cause this problem?

    / Bo



  • Olof Lagerkvist

    #2
    Re: Right$ doesn't work

    Bo Wisén wrote:
    [color=blue]
    > Hi,
    >
    > A project in VB6 recently worked without any problems but now it's
    > complaining when I try to use 'Right$'. In immediate mode, when I'm typing
    > 'print left$("123456", 2)' I get the correct result '12'. When I type 'print
    > right$("123456" ,2) I expect the result '56' but all I get is an error 'type
    > declaration does not match declared data type'. And I can't find that I have
    > tried to declare 'right'. Can anyone explain what can cause this problem?[/color]

    The problem may be that Right() is defined in another library referenced
    in your project.

    Try to use the full object path to the Right() function, like:
    Print VBA.Strings.Rig ht("123456", 2)

    If you want to know where the other "Right" is defined, press F2 to open
    the Object Browser and search for Right. It will show you all objects
    where "Right" is defined.

    --
    Olof Lagerkvist
    ICQ: 724451
    Web page: http://here.is/olof

    Comment

    • Bo Wisén

      #3
      Re: Right$ doesn't work


      "Olof Lagerkvist" <no@email.addre ss> skrev i meddelandet
      news:YK4hd.7559 $d5.63558@newsb .telia.net...
      : Bo Wisén wrote:
      :
      : > Hi,
      : >
      : > A project in VB6 recently worked without any problems but now it's
      : > complaining when I try to use 'Right$'. In immediate mode, when I'm
      typing
      : > 'print left$("123456", 2)' I get the correct result '12'. When I type
      'print
      : > right$("123456" ,2) I expect the result '56' but all I get is an error
      'type
      : > declaration does not match declared data type'. And I can't find that I
      have
      : > tried to declare 'right'. Can anyone explain what can cause this
      problem?
      :
      : The problem may be that Right() is defined in another library referenced
      : in your project.
      :
      : Try to use the full object path to the Right() function, like:
      : Print VBA.Strings.Rig ht("123456", 2)
      :
      : If you want to know where the other "Right" is defined, press F2 to open
      : the Object Browser and search for Right. It will show you all objects
      : where "Right" is defined.
      :
      : --
      : Olof Lagerkvist
      : ICQ: 724451
      : Web page: http://here.is/olof
      :


      Comment

      • Bo Wisén

        #4
        Re: Right$ doesn't work


        "Olof Lagerkvist" <no@email.addre ss> skrev i meddelandet
        news:YK4hd.7559 $d5.63558@newsb .telia.net...
        : Bo Wisén wrote:
        :
        : > Hi,
        : >
        : > A project in VB6 recently worked without any problems but now it's
        : > complaining when I try to use 'Right$'. In immediate mode, when I'm
        typing
        : > 'print left$("123456", 2)' I get the correct result '12'. When I type
        'print
        : > right$("123456" ,2) I expect the result '56' but all I get is an error
        'type
        : > declaration does not match declared data type'. And I can't find that I
        have
        : > tried to declare 'right'. Can anyone explain what can cause this
        problem?
        :
        : The problem may be that Right() is defined in another library referenced
        : in your project.
        :
        : Try to use the full object path to the Right() function, like:
        : Print VBA.Strings.Rig ht("123456", 2)
        :
        : If you want to know where the other "Right" is defined, press F2 to open
        : the Object Browser and search for Right. It will show you all objects
        : where "Right" is defined.
        :
        : --
        : Olof Lagerkvist
        : ICQ: 724451
        : Web page: http://here.is/olof

        Thanks!

        Writing 'Print VBA.Strings.Rig ht("123456", 2)' works but looking in the
        object browser 'left' is defined in the library 'Unknown3' but 'right' is
        not defined at all! If I open a new project 'right' works. What could be
        done?
        / Bo


        Comment

        • Olof Lagerkvist

          #5
          Re: Right$ doesn't work

          Bo Wisén wrote:
          [color=blue]
          > "Olof Lagerkvist" <no@email.addre ss> skrev i meddelandet
          > news:YK4hd.7559 $d5.63558@newsb .telia.net...
          > : Bo Wisén wrote:
          > :
          > : > Hi,
          > : >
          > : > A project in VB6 recently worked without any problems but now it's
          > : > complaining when I try to use 'Right$'. In immediate mode, when I'm
          > typing
          > : > 'print left$("123456", 2)' I get the correct result '12'. When I type
          > 'print
          > : > right$("123456" ,2) I expect the result '56' but all I get is an error
          > 'type
          > : > declaration does not match declared data type'. And I can't find that I
          > have
          > : > tried to declare 'right'. Can anyone explain what can cause this
          > problem?
          > :
          > : The problem may be that Right() is defined in another library referenced
          > : in your project.
          > :
          > : Try to use the full object path to the Right() function, like:
          > : Print VBA.Strings.Rig ht("123456", 2)
          > :
          > : If you want to know where the other "Right" is defined, press F2 to open
          > : the Object Browser and search for Right. It will show you all objects
          > : where "Right" is defined.
          >
          > Thanks!
          >
          > Writing 'Print VBA.Strings.Rig ht("123456", 2)' works but looking in the
          > object browser 'left' is defined in the library 'Unknown3' but 'right' is
          > not defined at all! If I open a new project 'right' works. What could be
          > done?[/color]

          Hmm... If VBA.Strings.Rig ht() would not have worked either and you find
          no definition of Right() in the object browser I would have suggested to
          check if the VBA library is referenced correctly, but now when
          VBA.Strings.Rig ht() works I do not know really...

          If you look in Project -> References in the project where Right() does
          not work, is the same "Visual Basic For Applications" library referenced
          there as it is in a new project? If not, select the same VBA library as
          you get for new projects. (This could be a bit tricky, you may have to
          edit the object references in the .vbp file manually.)

          --
          Olof Lagerkvist
          ICQ: 724451
          Web page: http://here.is/olof

          Comment

          • Steve Gerrard

            #6
            Re: Right$ doesn't work


            "Bo Wisén" <bowisen@telia. com> wrote in message
            news:GT5hd.7571 $d5.63372@newsb .telia.net...
            |
            | Writing 'Print VBA.Strings.Rig ht("123456", 2)' works but looking in
            the
            | object browser 'left' is defined in the library 'Unknown3' but 'right'
            is
            | not defined at all! If I open a new project 'right' works. What could
            be
            | done?
            | / Bo
            |

            I think you must have the object browser set to look only in the current
            project, instead of "<All Libraries>" or "VBA". This is set in the drop
            down list in the upper left corner of the browser.

            With "<All Libraries>" selected, the Left property should be listed for
            each of the standard VB controls, and you should also see it listed as a
            VBA function. Right should be a VBA function listing as well. You may
            then discover some other listing for Right, which is causing the
            original problem.



            Comment

            • Randy Birch

              #7
              Re: Right$ doesn't work

              Ensure that the first four selected (in order) items under
              project>referen ces are:

              visual basic for applications
              visual basic runtime objects and procedures
              visual basic objects and procedures
              OLE automation

              If another control or class has defined a Right method, VB will require you
              prefix with VBA.xxx in order to identify the particular Right method you
              want to use. Ditto for the other control/classes Right method.

              --


              Randy Birch
              MS MVP Visual Basic



              "Bo Wisén" <bowisen@telia. com> wrote in message
              news:GT5hd.7571 $d5.63372@newsb .telia.net...
              :
              : "Olof Lagerkvist" <no@email.addre ss> skrev i meddelandet
              : news:YK4hd.7559 $d5.63558@newsb .telia.net...
              : : Bo Wisin wrote:
              : :
              : : > Hi,
              : : >
              : : > A project in VB6 recently worked without any problems but now it's
              : : > complaining when I try to use 'Right$'. In immediate mode, when I'm
              : typing
              : : > 'print left$("123456", 2)' I get the correct result '12'. When I type
              : 'print
              : : > right$("123456" ,2) I expect the result '56' but all I get is an error
              : 'type
              : : > declaration does not match declared data type'. And I can't find that
              I
              : have
              : : > tried to declare 'right'. Can anyone explain what can cause this
              : problem?
              : :
              : : The problem may be that Right() is defined in another library referenced
              : : in your project.
              : :
              : : Try to use the full object path to the Right() function, like:
              : : Print VBA.Strings.Rig ht("123456", 2)
              : :
              : : If you want to know where the other "Right" is defined, press F2 to open
              : : the Object Browser and search for Right. It will show you all objects
              : : where "Right" is defined.
              : :
              : : --
              : : Olof Lagerkvist
              : : ICQ: 724451
              : : Web page: http://here.is/olof
              :
              : Thanks!
              :
              : Writing 'Print VBA.Strings.Rig ht("123456", 2)' works but looking in the
              : object browser 'left' is defined in the library 'Unknown3' but 'right' is
              : not defined at all! If I open a new project 'right' works. What could be
              : done?
              : / Bo
              :
              :

              Comment

              • J French

                #8
                Re: Right$ doesn't work

                On Sun, 31 Oct 2004 10:19:44 GMT, "Bo Wisén" <bowisen@telia. com>
                wrote:
                [color=blue]
                >Hi,
                >
                >A project in VB6 recently worked without any problems but now it's
                >complaining when I try to use 'Right$'. In immediate mode, when I'm typing
                >'print left$("123456", 2)' I get the correct result '12'. When I type 'print
                >right$("123456 ",2) I expect the result '56' but all I get is an error 'type
                >declaration does not match declared data type'. And I can't find that I have
                >tried to declare 'right'. Can anyone explain what can cause this problem?[/color]

                Stick the cursor on the rogue 'Right' and press Shift F2
                - see where the 'declaration tracer' takes you

                Comment

                • Bert Byfield

                  #9
                  Re: Right$ doesn't work

                  >>A project in VB6 recently worked without any problems but now it's[color=blue][color=green]
                  >>complaining when I try to use 'Right$'. In immediate mode, when I'm
                  >>typing 'print left$("123456", 2)' I get the correct result '12'. When I
                  >>type 'print right$("123456" ,2) I expect the result '56' but all I get
                  >>is an error 'type declaration does not match declared data type'. And
                  >>I can't find that I have tried to declare 'right'. Can anyone explain
                  >>what can cause this problem?[/color][/color]

                  The "$" declares "right" to be a string. Immediate mode is funny about how
                  you declare variables with a suffix. It keeps its own table of variables
                  and won't let you change it. Try "right" without the "$", which makes it a
                  variant and might undeclare it. The "2" might be a conflict, too.





                  Comment

                  Working...