Code to randomize based on different probability. $rec = RndwithProbablity('a=5,b=2,c=3') MsgBox(0,"",$rec) Func RndwithProbablity($valarray) Local $name[100], $val[100], $temp, $temp2, $total, $ptot, $ntot, $rnd $temp = StringSplit($valarray,",") $total = 0 For $i = 1 To $temp[0] $temp2 = StringSplit($temp[$i],"=") $name[$i] = $temp2[1] $val[$i] = $temp2[2] $total = $total + $temp2[2] Next $rnd = Random(1, $total, 1) For $i = 1 To $temp[0] $ntot = 0 For $j = 1 To $i