VB6 Fix

  • Thread starter Thread starter Starbuck
  • Start date Start date
S

Starbuck

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

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

vbfix = Fix(Math.Ceiling(g.MeasureString(ct, e.TextFont, 20,
StringFormat.GenericTypographic).Width))

End Function

Thanks
 
If I show you, can I have your job? No? How 'bout a week's pay? :)
 
Starbuck said:
Can anyone show me a pure .net equivelent of the VB6 Fix procedure as
below

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

vbfix = Fix(Math.Ceiling(g.MeasureString(ct, e.TextFont, 20,
StringFormat.GenericTypographic).Width))

End Function

Thanks


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(ct, e.TextFont, 20,
StringFormat.GenericTypographic).Width))


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

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

vbfix = Fix(Math.Ceiling(g.MeasureString(ct, e.TextFont, 20,
StringFormat.GenericTypographic).Width))

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.
 
Microsoft.VisualBasic.Fix and System.Math.Ceiling 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'?
 
Stephany Young said:
Microsoft.VisualBasic.Fix and System.Math.Ceiling can be considered, to
all intents and purposes, to be functionally equivalent.

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(Number)
End If
Return -Math.Floor(-Number)
End Function
///

Sample:

\\\
?Math.Ceiling(1.2) ' 2.
?Fix(1.2) ' 1.
///
 
Starbuck,
Microsoft.VisualBasic.Conversion.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

| Can anyone show me a pure .net equivelent of the VB6 Fix procedure as
below
|
| Function vbfix(ByVal ct As Char, ByVal e As DataGridcstrCellEventArgs,
ByVal
| g As System.Drawing.Graphics) As Double
|
| vbfix = Fix(Math.Ceiling(g.MeasureString(ct, e.TextFont, 20,
| StringFormat.GenericTypographic).Width))
|
| End Function
|
| Thanks
|
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top