Tienes un manantial de tutoriales en http://ricardonarvaja.info que esperan por ser leidos, y cualquier duda estamos dispuestos (en cuanto se pueda
) a resolver inquietudes
.
salu2
AmeRiK@nO



salu2
AmeRiK@nO
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCita de: Dudasamonton en 7 Abril 2009, 18:46 PM
Te dejo una clase que hice hace tiempo en forma de modulo.Imports classlibrary1.Fracciones
Module module1
Sub main()
Console.WriteLine((Fracciones.Lectura.tografico(Fracciones.Operaciones.FraccionIrreductible(Fracciones.Lectura.tofraccion(1024, 512)))))
Console.ReadLine()
End Sub
End ModuleNamespace Fracciones
Public Class Operaciones
Shared Function SumaFracciones(ByVal n1 As Integer, ByVal d1 As Integer, ByVal n2 As Integer, ByVal d2 As Integer) As String
Dim nn As Integer = (n1 * d2) + (n2 * d1), dn As Integer = d1 * d2
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function RestaFracciones(ByVal n11 As Integer, ByVal d11 As Integer, ByVal n22 As Integer, ByVal d22 As Integer) As String
Dim nn As Integer = (n11 * d22) - (n22 * d11), dn As Integer = d11 * d22
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function MultiplicarFracciones(ByVal n111 As Integer, ByVal d111 As Integer, ByVal n222 As Integer, ByVal d222 As Integer) As String
Dim nn As Integer = (n111 * n222), dn As Integer = (d111 * d222)
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function DividirFracciones(ByVal n1111 As Integer, ByVal d1111 As Integer, ByVal n2222 As Integer, ByVal d2222 As Integer) As String
Dim nn As Integer = (n1111 * d2222), dn As Integer = (n1111 * n2222)
Return Str(nn) + "/" + Str(dn)
End Function
Shared Function Fraccion2Decimal(ByVal numerador As Integer, ByVal denominador As Integer)
Return numerador / denominador
End Function
Shared Function FraccionIrreductible(ByVal fraccion As Integer()) As Integer()
Dim n As Integer = 2
While n <= Math.Max(fraccion(0), fraccion(1))
If fraccion(0) Mod n = 0 And fraccion(1) Mod n = 0 Then
fraccion(0) /= n
fraccion(1) /= n
End If
n += 1
End While
n = 2
n += 1
While n <= Math.Max(fraccion(0), fraccion(1))
If fraccion(0) Mod n = 0 And fraccion(1) Mod n = 0 Then
fraccion(0) /= n
fraccion(1) /= n
End If
n += 1
End While
Return fraccion
End Function
End Class
Public Class Lectura
Shared Function tofraccion(ByVal x As Integer, ByVal y As Integer) As Integer()
Dim newarray() As Integer = {Int(x), Int(y)}
Return newarray
End Function
Shared Function tografico(ByVal fraccion As Integer()) As String
Return fraccion(0) & "/" & fraccion(1)
End Function
End Class
End Namespace
Puede resultar liante, pero es lo primero que he encontrado en mi lista de archivos.