'And'ing a Byte Value - How?

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

    'And'ing a Byte Value - How?

    Folks, I get a TYPE MISMATCH complaint fm ASP when I do the following in
    trying to extract the high-order four bits. The complaint being that the
    strTemp value is a string. Well, yes - it's a 1-char string.

    NumTemp = MidB(strTemp,1, 1) And &Hf0

    What am I doing wrong? (Something dumb, I'm sure, but ... .)

    AS


  • Ray at

    #2
    Re: 'And'ing a Byte Value - How?

    Are you trying to concatenate? Use & instead of And.

    Ray at work

    "Arnold Shore" <ashore@saefern .org> wrote in message
    news:uq7R2WejDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Folks, I get a TYPE MISMATCH complaint fm ASP when I do the following in
    > trying to extract the high-order four bits. The complaint being that the
    > strTemp value is a string. Well, yes - it's a 1-char string.
    >
    > NumTemp = MidB(strTemp,1, 1) And &Hf0
    >
    > What am I doing wrong? (Something dumb, I'm sure, but ... .)
    >
    > AS
    >
    >[/color]


    Comment

    • Arnold Shore

      #3
      Re: 'And'ing a Byte Value - How?

      No. As I said, I'm trying to extract the HO bits. Thanks,
      AS

      "Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
      news:uYZ#hZejDH A.3700@TK2MSFTN GP11.phx.gbl...[color=blue]
      > Are you trying to concatenate? Use & instead of And.
      >
      > Ray at work
      >
      > "Arnold Shore" <ashore@saefern .org> wrote in message
      > news:uq7R2WejDH A.2140@TK2MSFTN GP09.phx.gbl...[color=green]
      > > Folks, I get a TYPE MISMATCH complaint fm ASP when I do the following[/color][/color]
      in[color=blue][color=green]
      > > trying to extract the high-order four bits. The complaint being that the
      > > strTemp value is a string. Well, yes - it's a 1-char string.
      > >
      > > NumTemp = MidB(strTemp,1, 1) And &Hf0
      > >
      > > What am I doing wrong? (Something dumb, I'm sure, but ... .)
      > >
      > > AS
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Chris Hohmann

        #4
        Re: 'And'ing a Byte Value - How?

        "Arnold Shore" <ashore@saefern .org> wrote in message
        news:uq7R2WejDH A.2140@TK2MSFTN GP09.phx.gbl...[color=blue]
        > Folks, I get a TYPE MISMATCH complaint fm ASP when I do the following[/color]
        in[color=blue]
        > trying to extract the high-order four bits. The complaint being that[/color]
        the[color=blue]
        > strTemp value is a string. Well, yes - it's a 1-char string.
        >
        > NumTemp = MidB(strTemp,1, 1) And &Hf0
        >
        > What am I doing wrong? (Something dumb, I'm sure, but ... .)[/color]

        NumTemp = AscB(strTemp) And &HF0

        Notes:
        1. No need to extract the first character, Asc/AscB/AscW only act on the
        first character in a string.
        2. Here is the reference page for Asc/AscB/AscW in VBScript:

        Gain technical skills through documentation and training, earn certifications and connect with the community


        HTH-
        Chris Hohmann


        Comment

        • Arnold Shore

          #5
          Re: 'And'ing a Byte Value - How?

          Yep. Now back to my question: How do I extract the extract the high-order
          four bits of a given Byte value?

          The logical "And" for that requires a numeric expression, and I have a Byte.

          AS

          "Chris Hohmann" <hohmannATyahoo DOTcom> wrote in message
          news:exH1tNfjDH A.2676@TK2MSFTN GP11.phx.gbl...
          ....[color=blue]
          > Notes:
          > 1. No need to extract the first character, Asc/AscB/AscW only act on the
          > first character in a string.
          > 2. Here is the reference page for Asc/AscB/AscW in VBScript:
          >
          > http://msdn.microsoft.com/library/en...l/vsfctasc.asp
          >
          > HTH-
          > Chris Hohmann
          >
          >[/color]


          Comment

          • Chris Hohmann

            #6
            Re: 'And'ing a Byte Value - How?

            "Arnold Shore" <ashore@saefern .org> wrote in message
            news:eBFYYXgjDH A.3732@tk2msftn gp13.phx.gbl...[color=blue]
            > Yep. Now back to my question: How do I extract the extract the[/color]
            high-order[color=blue]
            > four bits of a given Byte value?
            >
            > The logical "And" for that requires a numeric expression, and I have a[/color]
            Byte.

            TypeName(MidB(" SomeString",1,1 )) => String
            TypeName(AscB(" SomeString")) => Byte

            Did you try the following line?

            NumTemp = AscB(strTemp) And &HF0


            HTH
            -Chris Hohmann


            Comment

            • Mike Florio

              #7
              Re: 'And'ing a Byte Value - How?

              an example in javascript:

              <script language="javas cript">

              var a = 255;

              alert (a & 0xf0); // should return 240

              </script>




              "Arnold Shore" <ashore@saefern .org> wrote in message
              news:eBFYYXgjDH A.3732@tk2msftn gp13.phx.gbl...[color=blue]
              > Yep. Now back to my question: How do I extract the extract the[/color]
              high-order[color=blue]
              > four bits of a given Byte value?
              >
              > The logical "And" for that requires a numeric expression, and I have a[/color]
              Byte.[color=blue]
              >
              > AS
              >
              > "Chris Hohmann" <hohmannATyahoo DOTcom> wrote in message
              > news:exH1tNfjDH A.2676@TK2MSFTN GP11.phx.gbl...
              > ...[color=green]
              > > Notes:
              > > 1. No need to extract the first character, Asc/AscB/AscW only act on the
              > > first character in a string.
              > > 2. Here is the reference page for Asc/AscB/AscW in VBScript:
              > >
              > > http://msdn.microsoft.com/library/en...l/vsfctasc.asp
              > >
              > > HTH-
              > > Chris Hohmann
              > >
              > >[/color]
              >
              >[/color]


              Comment

              Working...