hello there, i need some help as my teacher gave us a very vague example on random number code and i'm stuck on doing my assigned homework. the assignment is to have three text boxes, generate random numbers between 1-10, and afterwards both automatically added together. so one text displays the first variable, the second box for the second variable, and the final box for the answer.

honestly this is far as i could go cause it seems so different to me then what we have done so far and i haven't had a chance to run this on VB as i'm not at school right now, the random in general confuses me on the 0,1 and the decimal

cmdCalculate
dim A As Integer
dim B As Integer

Public Function RandomNum (X as Integer) As Integer
Randomize
Random Nu=Int (X*Rnd)+1 {1,10}

firstNum=RandomNum(Limit)
txtFirstNum.text=Str$(A)

secondNum=RandomNum(Limit)
txtSecondNum=Str$(B)

so, how far you do this??show us your effort friend, cause We only give homework help to those who show effort.
Use Randomize() to get random number.

cmdCalculate
dim A As Integer
dim B As Integer

Public Function RandomNum (X as Integer) As Integer
Randomize
Random Nu=Int (X*Rnd)+1 {1,10}

C=A+B


firstNum=RandomNum(Limit)
txtFirstNum.text=Str$(A)

secondNum=RandomNum(Limit)
txtSecondNum=Str$(B)

txtAnswer=Str$(C)

see this :

Private Sub Command1_Click()
Dim FirstValue As Integer, SecondValue As Integer
FirstValue = Rnd * Val(Trim(Text1.Text)) + 1
SecondValue = Rnd * Val(Trim(Text1.Text)) + 1
Text2.Text = FirstValue
Text3.Text = SecondValue
Text4.Text = FirstValue + SecondValue
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.