Ryker Wells
Member
So I'm brand spankin' new to VB and so far am slowly understanding. But I've finally run across a problem i can't seem to find the answer to.
I'm working with a random number that generates a price for a house between 1 and 100 dollars (obviously very realistic).
My problem is that I put that number in the public class which does generate the number but only once. But i need the number to be re-generated every time a button is clicked. Now I would put this code snippet in the buttons Sub but there are 3 other subs in the code that call for that randomly generated number and the only way that I know of that allows all the subs to read this random number is to put it in the public class.
So how do I put the number in a place where all Subs can read it and can be called to re-generate when needed?
Thank you for your time and effort!
If you need any more info I'm glad to elaborate further.
I'm working with a random number that generates a price for a house between 1 and 100 dollars (obviously very realistic).
VB.NET:
Dim Housecost As Integer = (Int((100 * Rnd()) + 1))
My problem is that I put that number in the public class which does generate the number but only once. But i need the number to be re-generated every time a button is clicked. Now I would put this code snippet in the buttons Sub but there are 3 other subs in the code that call for that randomly generated number and the only way that I know of that allows all the subs to read this random number is to put it in the public class.
So how do I put the number in a place where all Subs can read it and can be called to re-generate when needed?
Thank you for your time and effort!
If you need any more info I'm glad to elaborate further.