Hi all have seen your forum, very helpfull. But i'm just starting whith visual basic, i'm using Microsoft Visual Basic 2005 Express Edition. I need to do a prog that calculate the number of kilometers that a do in a week monday to friday. It works like this i type the starting km and the final km and the prog calculate the km i did by day, displaying like this.

What i need to do now is to get the prog to make the ending km " km finais" to be random, but the final sum of the value must be iqual to (ending km - starting km). I made the code very simple, must like excel.
Private Sub calc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calc.Click
med.Text = (Val(kmf.Text) - Val(kmi.Text)) / 5
ki1.Text = Val(kmi.Text)
kf5.Text = Val(kmf.Text)
kf1.Text = Val(ki1.Text) + Val(med.Text)
ki2.Text = Val(kf1.Text)
kf2.Text = Val(ki2.Text) + Val(med.Text)
ki3.Text = Val(kf2.Text)
kf3.Text = Val(ki3.Text) + Val(med.Text)
ki4.Text = Val(kf3.Text)
kf4.Text = Val(ki4.Text) + Val(med.Text)
ki5.Text = Val(kf4.Text)
kf5.Text = Val(ki5.Text) + Val(med.Text)
kmfeitos.Text = Val(kmf.Text) - Val(kmi.Text)
End Sub
How can i make the kf?.Text random keeping the result of their sum be equal to kmf.Text - kmi.Text ??? i'm just lost. Sorry for language, i dont know how to write very well.
This post has been edited by ante: 5 Feb, 2007 - 02:23 PM