Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27020

VB loop help

$
0
0
Created this code however when I try to run it it crashes. I am very new to vb and have no idea how to fix the issue.

Public Class Form1


Dim years As Integer
Dim rate As Single
Dim currentYear As Long
Dim startingProfit As Single
Dim result As Integer
Dim result2 As Integer
Dim currentProfit As Integer

Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click

'Calculating the result of user input

years = 0

currentYear = Year(Date.Now)
startingProfit = 255000
currentProfit = startingProfit


Do While currentProfit <= 3000000


result = currentProfit / 100
result2 = result * rate
currentProfit = result2 + startingProfit

currentYear = currentYear + 1 'counter
Loop

lblResult.Text = "As at " & DateValue(Now) & "the profit margin in " & currentYear & "will be " & currentProfit & "."

End Sub
End Class

Viewing all articles
Browse latest Browse all 27020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>