vaibhav88
11-05-2011, 06:15 PM
Hello to all of you, I am Vaibhav Chauhan Masters Student at Lamar University I am new to programming hence I am working on my programming skills so that it will help me to understand the basic concepts of Heuristics.and as an exercise I wrote following code in my VBA module window but in the cell("a1") every time the answer is 5050,with this code I aim to get the sum of random numbers generated, Pls help and I would really appreciate for all the inputs provided by you guys but spare me of my errors as I am new to programming :)
Option Base 1
Function sumarray(x) As Double
sumarray = 0
For i = 1 To 100
sumarray = sumarray + i
Next i
End Function
Sub genarray()
Dim i(100) As Double
For ak = 1 To 100
a = Int((Rnd() * 100))
i(ak) = a
Next ak
Worksheets(1).Range("a1").Value = sumarray(i)
End Sub
Vaibhav Chauhan
s/w used EXCEl 2003
Option Base 1
Function sumarray(x) As Double
sumarray = 0
For i = 1 To 100
sumarray = sumarray + i
Next i
End Function
Sub genarray()
Dim i(100) As Double
For ak = 1 To 100
a = Int((Rnd() * 100))
i(ak) = a
Next ak
Worksheets(1).Range("a1").Value = sumarray(i)
End Sub
Vaibhav Chauhan
s/w used EXCEl 2003