# Rational issues :)

• ### Question

• User-1838403457 posted
`I'm compiling some code to use this function I got off the net.  The problem is when I compile in Visual Studio 2008 it says that Rational is not defined.  Is there a reference I need to add?  I found lots of examples that use Rational, but none talk about what you need to declare.    Private Function GetRational(ByVal B As Byte()) As Rational        Dim R As New Rational, N(3), D(3) As Byte        Array.Copy(B, 0, N, 0, 4)        Array.Copy(B, 4, D, 0, 4)        R.Denominator = Me.GetInt32(D)        R.Numerator = Me.GetInt32(N)        Return R    End Function`
Thursday, December 23, 2010 5:43 PM

### All replies

• User-364289655 posted

You're going to need to provide a bit more information - where is Rational defined. Secondly, you call a Me.Rational - so I assume this is in some object that has a Rational Object? More of your code would be helpful - if you don't have more code, then a description of what you are trying to do so that I could create a new function that does that for you would be nice.

~P

Thursday, December 23, 2010 7:03 PM
• User-158764254 posted

There is a Rational structure: http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.common.rational(VS.93).aspx

that  is included in the Misrosoft Solver foundation: http://www.solverfoundation.com/

• Marked as answer by Thursday, October 7, 2021 12:00 AM
Thursday, December 23, 2010 7:14 PM
• User-364289655 posted

Thanks Mike - that helps somewhat.

Without more details regarding the error, and assuming you have the correct namespace imported to use Rational, then I think you need to convert your getInt32 to BitConverter.ToInt32:

```Private Function GetRational(ByVal B As Byte()) As Rational
Dim R As New Rational, N(3), D(3) As Byte
Array.Copy(B, 0, N, 0, 4)
Array.Copy(B, 4, D, 0, 4)
R.Denominator = BitConverter.ToInt32(D, 0)
R.Numerator = BitConverter.ToInt32(N, 0)
Return R
End Function```

Thursday, December 23, 2010 7:24 PM