VB6 Fix

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

    #1

    VB6 Fix

    Can anyone show me a pure .net equivelent of the VB6 Fix procedure as below

    Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCel lEventArgs, ByVal
    g As System.Drawing. Graphics) As Double

    vbfix = Fix(Math.Ceilin g(g.MeasureStri ng(ct, e.TextFont, 20,
    StringFormat.Ge nericTypographi c).Width))

    End Function

    Thanks




  • Steve Schroeder

    #2
    Re: VB6 Fix

    If I show you, can I have your job? No? How 'bout a week's pay? :)

    "Starbuck" <admin@tisconi. com> wrote in message
    news:42937c6b$0 $15486$ed2619ec @ptn-nntp-reader01.plus.n et...[color=blue]
    > Can anyone show me a pure .net equivelent of the VB6 Fix procedure as[/color]
    below[color=blue]
    >
    > Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCel lEventArgs,[/color]
    ByVal[color=blue]
    > g As System.Drawing. Graphics) As Double
    >
    > vbfix = Fix(Math.Ceilin g(g.MeasureStri ng(ct, e.TextFont, 20,
    > StringFormat.Ge nericTypographi c).Width))
    >
    > End Function
    >
    > Thanks
    >
    >
    >
    >[/color]


    Comment

    • Starbuck

      #3
      Re: VB6 Fix

      Any helpful answers out there


      "Steve Schroeder" <sschroeder@som ewhere.com> wrote in message
      news:OEQeRWJYFH A.3280@TK2MSFTN GP09.phx.gbl...[color=blue]
      > If I show you, can I have your job? No? How 'bout a week's pay? :)
      >
      > "Starbuck" <admin@tisconi. com> wrote in message
      > news:42937c6b$0 $15486$ed2619ec @ptn-nntp-reader01.plus.n et...[color=green]
      >> Can anyone show me a pure .net equivelent of the VB6 Fix procedure as[/color]
      > below[color=green]
      >>
      >> Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCel lEventArgs,[/color]
      > ByVal[color=green]
      >> g As System.Drawing. Graphics) As Double
      >>
      >> vbfix = Fix(Math.Ceilin g(g.MeasureStri ng(ct, e.TextFont, 20,
      >> StringFormat.Ge nericTypographi c).Width))
      >>
      >> End Function
      >>
      >> Thanks
      >>
      >>
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Mythran

        #4
        Re: VB6 Fix


        "Starbuck" <admin@tisconi. com> wrote in message
        news:42937c6b$0 $15486$ed2619ec @ptn-nntp-reader01.plus.n et...[color=blue]
        > Can anyone show me a pure .net equivelent of the VB6 Fix procedure as
        > below
        >
        > Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCel lEventArgs,
        > ByVal g As System.Drawing. Graphics) As Double
        >
        > vbfix = Fix(Math.Ceilin g(g.MeasureStri ng(ct, e.TextFont, 20,
        > StringFormat.Ge nericTypographi c).Width))
        >
        > End Function
        >
        > Thanks
        >
        >
        >
        >[/color]


        AFAIK, Math.Ceiling performs the same thing as Fix function does. Unless I
        am corrected, then the same function body "could be":

        Return Math.Ceiling(g. MeasureString(c t, e.TextFont, 20,
        StringFormat.Ge nericTypographi c).Width))


        Mythran

        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: VB6 Fix

          "Starbuck" <admin@tisconi. com> schrieb:[color=blue]
          > Can anyone show me a pure .net equivelent of the VB6 Fix procedure as
          > below
          >
          > Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCel lEventArgs,
          > ByVal g As System.Drawing. Graphics) As Double
          >
          > vbfix = Fix(Math.Ceilin g(g.MeasureStri ng(ct, e.TextFont, 20,
          > StringFormat.Ge nericTypographi c).Width))[/color]

          There is no direct replacement for 'Fix' available in the .NET Framework. I
          suggest to use 'Fix' instead of writing your own replacement using
          'System.Math'. BTW: 'Fix' is part of Visual Basic .NET and it will remain
          part of it. There are absolutely no reasons to avoid using it.

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • Stephany Young

            #6
            Re: VB6 Fix

            Microsoft.Visua lBasic.Fix and System.Math.Cei ling can be considered, to all
            intents and purposes, to be functionally equivalent. Therefore, in your
            example, the use of both is overkill. Pick the one that suits the way you
            are feeling at the time.

            I am curious, however, as to why you consider the example you have shown to
            be not 'pure .net'?


            "Starbuck" <admin@tisconi. com> wrote in message
            news:42937c6b$0 $15486$ed2619ec @ptn-nntp-reader01.plus.n et...[color=blue]
            > Can anyone show me a pure .net equivelent of the VB6 Fix procedure as
            > below
            >
            > Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCel lEventArgs,
            > ByVal g As System.Drawing. Graphics) As Double
            >
            > vbfix = Fix(Math.Ceilin g(g.MeasureStri ng(ct, e.TextFont, 20,
            > StringFormat.Ge nericTypographi c).Width))
            >
            > End Function
            >
            > Thanks
            >
            >
            >
            >[/color]


            Comment

            • Herfried K. Wagner [MVP]

              #7
              Re: VB6 Fix

              "Stephany Young" <noone@localhos t> schrieb:[color=blue]
              > Microsoft.Visua lBasic.Fix and System.Math.Cei ling can be considered, to
              > all intents and purposes, to be functionally equivalent.[/color]

              That's not true in general. 'Fix' is implemented as this:

              \\\
              Public Function Fix(ByVal Number As Double) As Double
              If Number >= 0 Then
              Return Math.Floor(Numb er)
              End If
              Return -Math.Floor(-Number)
              End Function
              ///

              Sample:

              \\\
              ?Math.Ceiling(1 .2) ' 2.
              ?Fix(1.2) ' 1.
              ///

              --
              M S Herfried K. Wagner
              M V P <URL:http://dotnet.mvps.org/>
              V B <URL:http://classicvb.org/petition/>

              Comment

              • Jay B. Harlow [MVP - Outlook]

                #8
                Re: VB6 Fix

                Starbuck,
                Microsoft.Visua lBasic.Conversi on.Fix is the Pure .NET Equivalent of the VB6
                Fix procedure!

                You could implement (duplicate the code) Conversion.Fix & Conversion.Int in
                terms of Math.Floor & Math.Ceiling, however that would be a lot of
                duplicated code as Fix & Int are overloaded for must numeric types (Decimal,
                Double, Integer, Long, Object, Short, Single), where as Math.Floor &
                Math.Ceiling are only implemented in terms of Double.

                Hope this helps
                Jay

                "Starbuck" <admin@tisconi. com> wrote in message
                news:42937c6b$0 $15486$ed2619ec @ptn-nntp-reader01.plus.n et...
                | Can anyone show me a pure .net equivelent of the VB6 Fix procedure as
                below
                |
                | Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCel lEventArgs,
                ByVal
                | g As System.Drawing. Graphics) As Double
                |
                | vbfix = Fix(Math.Ceilin g(g.MeasureStri ng(ct, e.TextFont, 20,
                | StringFormat.Ge nericTypographi c).Width))
                |
                | End Function
                |
                | Thanks
                |
                |
                |
                |


                Comment

                Working...