While working with Millis loop is there anyway a counter can be added?

While working with Millis loop is there anyway a counter can be added? I don’t seem to be getting the counter added out of it correctly, yes I am new. I am trying to pull the average of the sample.

while (millis() - startMillis < SAMPLE_WINDOW)
{
sample = analogRead(MIC_PIN);
sampleAdd = sample + sampleAdd;
countSample = countSample + 1;
}

sampleAvg = sampleAdd / countSample;
countSample = 0;

What variable types are you using? Are they rolling over? Can you post your code to http://gist.github.com ?

Here is the link to the code.