I am quite sure I am gonna feel real dumb when I found where I am screwing up but I am ALMOST done with a fraction calculator (part of a complete algebraic calculator I am making) and am stuck when trying to reduce my fraction because when I hit the reduce button, it only divides the answer by the first number in my listbox instead of all of the numbers.

So far, I have this code.

Private Sub Reduce(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_reduce.Click
        Dim Reduce As Double, i As Double, Result As Double
            Reduce = CDbl(lstCommon.Items(i))
            Result = txtNum5.Text / Reduce
            txtNum6.Text = Result.ToString("#,###.##")
            Result = txtDenom5.Text / Reduce
            txtDenom6.Text = Result.ToString("#,###.##")
        Loop Until lstCommon.Items.Count = 0
    End Sub

Problem I am finding with my code is that it will not put Result in txtNum6.Text or txtDenom6.Text and will not remove Reduce from lstCommon.

Thanks in advance for any help you all can provide.

Heres my Reduce Fraction Sub I made. It might help you out.

Private Sub ReduceFraction(ByRef Numerator As Integer, ByRef Denominator As Integer)
    If Numerator = 0 OrElse Denominator = 0 Then Exit Sub
    Dim CommonDenominator As Integer = 1

    For i = Numerator To 1 Step -1
      If Denominator Mod i = 0 AndAlso Numerator Mod i = 0 Then
          CommonDenominator = i
          Exit For
      End If

     Numerator = CInt(Numerator / CommonDenominator)
     Denominator = CInt(Denominator / CommonDenominator)
 End Sub

Using it

Dim Numerator As Integer = 2
  Dim Denominator As Integer = 8

  ReduceFraction(Numerator, Denominator)

Numerator will now be 1 and denominator will now be 4.

I keep forgetting about the Mod function when it comes to my algebraic calculator. I figured i would be feeling retarded and you reminded me of how much of a new VB.Net programmer I am.

This question has already been answered. Start a new discussion instead.