My code
#include <stdio.h>
#include <time.h>
#include<stdlib.h>
float randomnumber(double x)
{
// when input a number(x). Ex 99.5
// this function will return ramdom a (double)number between 98.2%*x to 101.8%*x
double a = 0;
srand(time(0));
a = (1 + rand() % 36) / 1000;
return x * (0.982 + a);
}
float _stdcall randnumber(double x)
{
double a = 0;
do
{
a = randomnumber(x);
}while (a > 100 || a == 100);
return a;
}
def file
LIBRARY "square"
EXPORTS
RandNum = randnumber
I call it in excel-vba as function. When i use it, it randoms corectly in first time, but ... When i calculate workbook manually (Fress F9 or re-enter), it does not change number. Why it does not work?