VB.Net 2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Herfried K. Wagner [MVP]

    #16
    Re: VB.Net 2005

    * "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> scripsit:[color=blue]
    > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
    > news:OuPHSxwaEH A.524@TK2MSFTNG P09.phx.gbl...
    >[color=green]
    >> MyShort = MyShort And ValueOf( c )[/color]
    >
    > Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only
    > place I could find this was under JScript[.NET].[/color]

    It's pseudo code, or in other words, a method that takes a string
    consisting of "0" and "1" characters. 'ValueOf' would return its
    integer value.

    Still, performance will be bad, especially for longer strings. Natively
    supporting binary number /literals/ that are converted at compile-time
    would be a far better approach.

    Currently, you can use this code to get the behavior of 'ValueOf':

    \\\
    Public Function ValueOf(ByVal BinaryString As String) As Integer
    Return Convert.ToInt32 (BinaryString, 2)
    End Function
    ///

    --
    Herfried K. Wagner [MVP]
    <URL:http://dotnet.mvps.org/>

    Comment

    • Herfried K. Wagner [MVP]

      #17
      Re: VB.Net 2005

      Jay,

      * "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> scripsit:[color=blue]
      > I normally use:
      >[color=green]
      >> <Flags()> _
      >> Public Enum Goo
      >> None = 0
      >> A = 1 << 0
      >> B = 1 << 1
      >> C = 1 << 2
      >> D = 1 << 3
      >> End Enum[/color]
      >
      > Where the 1 is shifted over the bit position.[/color]

      Full ACK. I prefer this way too.
      [color=blue]
      > I agree I've wanted binary constants once or twice.[/color]

      I just throught in which situations binary number literals would make
      sense, and the case of a little enum was one of the most useful cases I
      was able to find. So, in everyday programming, binary number literals
      don't make much sense, which still doesn't mean that it should not be
      possible to use them ;-).

      --
      Herfried K. Wagner [MVP]
      <URL:http://dotnet.mvps.org/>

      Comment

      • Cor Ligthert

        #18
        Re: VB.Net 2005

        >[color=blue]
        > Full ACK. I prefer this way too.
        >[color=green]
        > > I agree I've wanted binary constants once or twice.[/color]
        >
        > I just throught in which situations binary number literals would make
        > sense, and the case of a little enum was one of the most useful cases I
        > was able to find. So, in everyday programming, binary number literals
        > don't make much sense, which still doesn't mean that it should not be
        > possible to use them ;-).[/color]

        Again why? Because sometimes to much is no benefit, it can make simple
        things suddenly more difficult. Example OR and ELSE.

        Cor


        Comment

        • One Handed Man \( OHM - Terry Burns \)

          #19
          Re: VB.Net 2005

          Yes, I agree completely, however, in the absence of those binary literals,
          if the OP wanted to be able to write out a string of ones and zeros in the
          programming then this is one option available now.

          Given that Visual Basic, has little support for accessing the pc's IO, its
          probably not much of a requirement.

          --

          OHM ( Terry Burns )
          . . . One-Handed-Man . . .

          Time flies when you don't know what you're doing

          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:elcDzh0aEH A.904@TK2MSFTNG P09.phx.gbl...[color=blue]
          > * "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> scripsit:[color=green]
          > > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color][/color]
          message[color=blue][color=green]
          > > news:OuPHSxwaEH A.524@TK2MSFTNG P09.phx.gbl...
          > >[color=darkred]
          > >> MyShort = MyShort And ValueOf( c )[/color]
          > >
          > > Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only
          > > place I could find this was under JScript[.NET].[/color]
          >
          > It's pseudo code, or in other words, a method that takes a string
          > consisting of "0" and "1" characters. 'ValueOf' would return its
          > integer value.
          >
          > Still, performance will be bad, especially for longer strings. Natively
          > supporting binary number /literals/ that are converted at compile-time
          > would be a far better approach.
          >
          > Currently, you can use this code to get the behavior of 'ValueOf':
          >
          > \\\
          > Public Function ValueOf(ByVal BinaryString As String) As Integer
          > Return Convert.ToInt32 (BinaryString, 2)
          > End Function
          > ///
          >
          > --
          > Herfried K. Wagner [MVP]
          > <URL:http://dotnet.mvps.org/>[/color]


          Comment

          • One Handed Man \( OHM - Terry Burns \)

            #20
            Re: VB.Net 2005

            Actually, it's one of those things you almost never want to do, so I was
            suprised that this overloaded ToInt32 had no less than ( 19 ) overloads and
            one of them did the trick, well spotted H.

            Regards - OHM

            --

            OHM ( Terry Burns )
            . . . One-Handed-Man . . .

            Time flies when you don't know what you're doing

            "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
            news:eqE46E1aEH A.1732@TK2MSFTN GP09.phx.gbl...[color=blue]
            > Yes, I agree completely, however, in the absence of those binary literals,
            > if the OP wanted to be able to write out a string of ones and zeros in the
            > programming then this is one option available now.
            >
            > Given that Visual Basic, has little support for accessing the pc's IO, its
            > probably not much of a requirement.
            >
            > --
            >
            > OHM ( Terry Burns )
            > . . . One-Handed-Man . . .
            >
            > Time flies when you don't know what you're doing
            >
            > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
            > news:elcDzh0aEH A.904@TK2MSFTNG P09.phx.gbl...[color=green]
            > > * "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> scripsit:[color=darkred]
            > > > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color][/color]
            > message[color=green][color=darkred]
            > > > news:OuPHSxwaEH A.524@TK2MSFTNG P09.phx.gbl...
            > > >
            > > >> MyShort = MyShort And ValueOf( c )
            > > >
            > > > Is ValueOf() somthing you wrote yourself? I looked in MSDN and the[/color][/color][/color]
            only[color=blue][color=green][color=darkred]
            > > > place I could find this was under JScript[.NET].[/color]
            > >
            > > It's pseudo code, or in other words, a method that takes a string
            > > consisting of "0" and "1" characters. 'ValueOf' would return its
            > > integer value.
            > >
            > > Still, performance will be bad, especially for longer strings. Natively
            > > supporting binary number /literals/ that are converted at compile-time
            > > would be a far better approach.
            > >
            > > Currently, you can use this code to get the behavior of 'ValueOf':
            > >
            > > \\\
            > > Public Function ValueOf(ByVal BinaryString As String) As Integer
            > > Return Convert.ToInt32 (BinaryString, 2)
            > > End Function
            > > ///
            > >
            > > --
            > > Herfried K. Wagner [MVP]
            > > <URL:http://dotnet.mvps.org/>[/color]
            >
            >[/color]


            Comment

            • Herfried K. Wagner [MVP]

              #21
              Re: VB.Net 2005

              * Cor Ligthert <notfirstname@p lanet.nl> scripsit:[color=blue][color=green]
              >> Full ACK. I prefer this way too.
              >>[color=darkred]
              >>> I agree I've wanted binary constants once or twice.[/color]
              >>
              >> I just throught in which situations binary number literals would make
              >> sense, and the case of a little enum was one of the most useful cases I
              >> was able to find. So, in everyday programming, binary number literals
              >> don't make much sense, which still doesn't mean that it should not be
              >> possible to use them ;-).[/color]
              >
              > Again why? Because sometimes to much is no benefit, it can make simple
              > things suddenly more difficult. Example OR and ELSE.[/color]

              I am not against binary integer number literals...

              --
              Herfried K. Wagner [MVP]
              <URL:http://dotnet.mvps.org/>

              Comment

              • Jeff Johnson [MVP: VB]

                #22
                Re: VB.Net 2005


                "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
                news:%23yAQaf0a EHA.1652@TK2MSF TNGP09.phx.gbl. ..
                [color=blue]
                > No it's Pseudo code.[/color]

                Mental block. I virtually never use pseudo code myself and the rest of the
                stuff you looked so "real" it didn't occur to me, regardless of the large
                PSUEDO! in your post....


                Comment

                • Jay B. Harlow [MVP - Outlook]

                  #23
                  Re: VB.Net 2005

                  Herfried,[color=blue]
                  > I just throught in which situations binary number literals would make[/color]

                  I like the term "binary number literals" better then my "binary
                  constants"...

                  Jay

                  "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                  news:uTDkyh0aEH A.3476@tk2msftn gp13.phx.gbl...[color=blue]
                  > Jay,
                  >
                  > * "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> scripsit:[color=green]
                  > > I normally use:
                  > >[color=darkred]
                  > >> <Flags()> _
                  > >> Public Enum Goo
                  > >> None = 0
                  > >> A = 1 << 0
                  > >> B = 1 << 1
                  > >> C = 1 << 2
                  > >> D = 1 << 3
                  > >> End Enum[/color]
                  > >
                  > > Where the 1 is shifted over the bit position.[/color]
                  >
                  > Full ACK. I prefer this way too.
                  >[color=green]
                  > > I agree I've wanted binary constants once or twice.[/color]
                  >
                  > I just throught in which situations binary number literals would make
                  > sense, and the case of a little enum was one of the most useful cases I
                  > was able to find. So, in everyday programming, binary number literals
                  > don't make much sense, which still doesn't mean that it should not be
                  > possible to use them ;-).
                  >
                  > --
                  > Herfried K. Wagner [MVP]
                  > <URL:http://dotnet.mvps.org/>[/color]


                  Comment

                  • One Handed Man \( OHM - Terry Burns \)

                    #24
                    Re: VB.Net 2005

                    LOL

                    --

                    OHM ( Terry Burns )
                    . . . One-Handed-Man . . .

                    Time flies when you don't know what you're doing

                    "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> wrote in message
                    news:%23VP2pY2a EHA.3016@tk2msf tngp13.phx.gbl. ..[color=blue]
                    >
                    > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                    message[color=blue]
                    > news:%23yAQaf0a EHA.1652@TK2MSF TNGP09.phx.gbl. ..
                    >[color=green]
                    > > No it's Pseudo code.[/color]
                    >
                    > Mental block. I virtually never use pseudo code myself and the rest of the
                    > stuff you looked so "real" it didn't occur to me, regardless of the large
                    > PSUEDO! in your post....
                    >
                    >[/color]


                    Comment

                    • One Handed Man \( OHM - Terry Burns \)

                      #25
                      Re: VB.Net 2005

                      I quickly knocked up this implementation. However, as H pointed out,
                      Convert.ToShort ("0000000000001 00",2) Does the same thing and I tested the
                      performance, its four times quicker than my code as you might expect. But
                      here it is for interest sake.

                      Public Function ToShort(ByVal str As String) As Short

                      Dim x As Int16
                      Dim i As Int16

                      For i = 0 To 14

                      If Char.GetNumeric Value(str, i) = 1 Then
                      x = x Or &H1
                      End If

                      x = x << 1

                      Next
                      Return x

                      End Function

                      --

                      OHM ( Terry Burns )
                      . . . One-Handed-Man . . .

                      Time flies when you don't know what you're doing

                      "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> wrote in message
                      news:%23VP2pY2a EHA.3016@tk2msf tngp13.phx.gbl. ..[color=blue]
                      >
                      > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                      message[color=blue]
                      > news:%23yAQaf0a EHA.1652@TK2MSF TNGP09.phx.gbl. ..
                      >[color=green]
                      > > No it's Pseudo code.[/color]
                      >
                      > Mental block. I virtually never use pseudo code myself and the rest of the
                      > stuff you looked so "real" it didn't occur to me, regardless of the large
                      > PSUEDO! in your post....
                      >
                      >[/color]


                      Comment

                      • Herfried K. Wagner [MVP]

                        #26
                        Re: VB.Net 2005

                        * "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> scripsit:[color=blue][color=green]
                        >> I just throught in which situations binary number literals would make[/color]
                        >
                        > I like the term "binary number literals" better then my "binary
                        > constants"...[/color]

                        Well, I didn't know the right term to use and then I took a look in the
                        documentation to use an appropriate term ;-).

                        --
                        Herfried K. Wagner [MVP]
                        <URL:http://dotnet.mvps.org/>

                        Comment

                        • Dennis D.

                          #27
                          Re: VB.Net 2005

                          I believe one of the rules of higher level languages is that the higher
                          level language 'must' accomodate all objects found in the lower level
                          languages (here: assembly). Keep in mind this code is used primarily by
                          machines, not by humans.

                          The Machine Imperatives



                          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                          news:elcDzh0aEH A.904@TK2MSFTNG P09.phx.gbl...[color=blue]
                          > * "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> scripsit:[color=green]
                          > > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color][/color]
                          message[color=blue][color=green]
                          > > news:OuPHSxwaEH A.524@TK2MSFTNG P09.phx.gbl...
                          > >[color=darkred]
                          > >> MyShort = MyShort And ValueOf( c )[/color]
                          > >
                          > > Is ValueOf() somthing you wrote yourself? I looked in MSDN and the only
                          > > place I could find this was under JScript[.NET].[/color]
                          >
                          > It's pseudo code, or in other words, a method that takes a string
                          > consisting of "0" and "1" characters. 'ValueOf' would return its
                          > integer value.
                          >
                          > Still, performance will be bad, especially for longer strings. Natively
                          > supporting binary number /literals/ that are converted at compile-time
                          > would be a far better approach.
                          >
                          > Currently, you can use this code to get the behavior of 'ValueOf':
                          >
                          > \\\
                          > Public Function ValueOf(ByVal BinaryString As String) As Integer
                          > Return Convert.ToInt32 (BinaryString, 2)
                          > End Function
                          > ///
                          >
                          > --
                          > Herfried K. Wagner [MVP]
                          > <URL:http://dotnet.mvps.org/>[/color]


                          Comment

                          • Dennis D.

                            #28
                            Re: VB.Net 2005

                            Oops: Here's a URL on Imperative Programming:

                            "DND" Do not dismiss as unimportant; ever. - me

                            "Dennis D." <tech@dennisys. com> wrote in message
                            news:ef6GpDnfEH A.708@TK2MSFTNG P09.phx.gbl...[color=blue]
                            > I believe one of the rules of higher level languages is that the higher
                            > level language 'must' accomodate all objects found in the lower level
                            > languages (here: assembly). Keep in mind this code is used primarily by
                            > machines, not by humans.
                            >
                            > The Machine Imperatives
                            > http://www.dennisys.com/
                            >
                            >
                            > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
                            > news:elcDzh0aEH A.904@TK2MSFTNG P09.phx.gbl...[color=green]
                            > > * "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> scripsit:[color=darkred]
                            > > > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color][/color]
                            > message[color=green][color=darkred]
                            > > > news:OuPHSxwaEH A.524@TK2MSFTNG P09.phx.gbl...
                            > > >
                            > > >> MyShort = MyShort And ValueOf( c )
                            > > >
                            > > > Is ValueOf() somthing you wrote yourself? I looked in MSDN and the[/color][/color][/color]
                            only[color=blue][color=green][color=darkred]
                            > > > place I could find this was under JScript[.NET].[/color]
                            > >
                            > > It's pseudo code, or in other words, a method that takes a string
                            > > consisting of "0" and "1" characters. 'ValueOf' would return its
                            > > integer value.
                            > >
                            > > Still, performance will be bad, especially for longer strings. Natively
                            > > supporting binary number /literals/ that are converted at compile-time
                            > > would be a far better approach.
                            > >
                            > > Currently, you can use this code to get the behavior of 'ValueOf':
                            > >
                            > > \\\
                            > > Public Function ValueOf(ByVal BinaryString As String) As Integer
                            > > Return Convert.ToInt32 (BinaryString, 2)
                            > > End Function
                            > > ///
                            > >
                            > > --
                            > > Herfried K. Wagner [MVP]
                            > > <URL:http://dotnet.mvps.org/>[/color]
                            >
                            >[/color]


                            Comment

                            • Dennis D.

                              #29
                              Re: VB.Net 2005

                              Excuse me for interupting:
                              Time flies when you don't know what you're doing
                              That is a great saying!
                              Where do you get your tag lines?

                              Dennis D.



                              "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in message
                              news:uDt9hp2aEH A.4048@TK2MSFTN GP10.phx.gbl...[color=blue]
                              > LOL
                              >
                              > --
                              >
                              > OHM ( Terry Burns )
                              > . . . One-Handed-Man . . .
                              >
                              > Time flies when you don't know what you're doing
                              >
                              > "Jeff Johnson [MVP: VB]" <i.get@enough.s pam> wrote in message
                              > news:%23VP2pY2a EHA.3016@tk2msf tngp13.phx.gbl. ..[color=green]
                              > >
                              > > "One Handed Man ( OHM - Terry Burns )" <news.microsoft .com> wrote in[/color]
                              > message[color=green]
                              > > news:%23yAQaf0a EHA.1652@TK2MSF TNGP09.phx.gbl. ..
                              > >[color=darkred]
                              > > > No it's Pseudo code.[/color]
                              > >
                              > > Mental block. I virtually never use pseudo code myself and the rest of[/color][/color]
                              the[color=blue][color=green]
                              > > stuff you looked so "real" it didn't occur to me, regardless of the[/color][/color]
                              large[color=blue][color=green]
                              > > PSUEDO! in your post....
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              Working...