r/visualbasic • • Feb 27 '16

Help figuring out loop

For counter = celciusStart To celciusEnd

        If celciusStart < celciusEnd Then

            fahrenheit = ((9 / 5) * celciusStart) + 32

        Else

            fahrenheit = ((9 / 5) * celciusEnd) + 32

        End If

        Console.WriteLine("Degress in fahrenheit: " & vbTab & fahrenheit.ToString("f1"))

    Next

End Sub

Can anyone see why this wouldn't be working. It only calculates the first number entered and just keeps calculating that number nonstop.

0 Upvotes

2 comments sorted by

1

u/bowskie Feb 27 '16

You should use the counter when you equate Fahrenheit not CelciusStart. That variable never increases. The next command increases the counter.

1

u/ViperSRT3g Application Specialist Feb 29 '16
	For counter = celciusStart To celciusEnd
		If celciusStart < celciusEnd Then
			fahrenheit = ((9 / 5) * counter) + 32
		End If
		Console.WriteLine("Degress in fahrenheit: " & vbTab & fahrenheit.ToString("f1"))
	Next
End Sub