private sub command1_click() dim i,s as integer s=0 for i=1 to 10000 s=s+i if s>=30000 then msgbox "the max N is:" & i-1 & "." exit sub endif next iend sub