Public Function GetGCD(ByVal Int1 As Integer, ByVal Int2 As Integer) As Integer '小さいほうを探す Dim Mini As Integer = Math.Min(Int1, Int2) Dim Int1_List As New List(Of Integer) Dim OKList As New List(Of Integer) Dim inting As Double 'Int1を確認 For i As Integer = 1 To Mini inting = Int1 / i If Not IsDecimal(inting) Then Int1_List.Add(i) End If Next 'Int2を確認 For i As Integer = 1 To Mini inting = Int2 / i If Not IsDecimal(inting) AndAlso Int1_List.Contains(i) Then 'ここを改良しました。 OKList.Add(i) End If Next Return OKList(OKList.Count - 1) End Function
Sub Main() Application.EnableVisualStyles() Dim f As New Fraction(5, 87) MsgBox(f.ToDouble) End Sub
IsDecimal False Nomber 1.25