VBA Excel array error -


i have generate id using macro , i'm facing problems when there 8 numeric values required. id has include numeric values 1st-8th charactera , 9th must alphabetic. 10th character onwards has spaces. these codes , i'm there no issues formula

function generaterb()  strlastcharselections = "x,w,m,l,k,j,e,d,c,b,a"  intnumber = generaterandomnumber(1000000, 9999999)  redim a(8) = 1 8 a(i) = mid(intnumber, i, 1) next  inttotal = a(1) * 9 + a(2) * 8 + a(3) * 7 + a(4) * 6 + a(5) * 5 + a(6) * 4 + a(7) * 3 + a(8) * 2   intremainder = inttotal mod 11  arrstrsplitlastcharselections = split(strlastcharselections, ",") strlastchar = arrstrsplitlastcharselections(intremainder) generaterb = intnumber & strlastchar end function 

the code works when its

    redim a(7) = 1 7 a(i) = mid(intnumber, i, 1) next  inttotal = a(1) * 9 + a(2) * 8 + a(3) * 7 + a(4) * 6 + a(5) * 5 + a(6) * 4 + a(7) * 3 

any appreciated i'm new this, thank you!

i'm assuming generaterandomnnumber return numeric in specified range - in case, 7 digit number between 1000000 , 9999999.

so when selecting ith digit in statement a(i) = mid(intnumber, i, 1), there no issues when i 1 7 - however, when it's 8 - there no eighth digit, code fail.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -