y=x+2 [0,4] y=x*x-6*x+12 [4,8], 分别输入0、4、8 private sub command1_click() x1=val(text1.text) x2=val(text2.text) x3=val(text3.text) t=x1+2 s=x2*x2-6*x2+12 for i = x1 to x2 step 0.01 y=i+2 if y>t then t=y next i for i = x2 to x3 step 0.01 y=i*i-6*i+12 if y>s then s=y next i msgbox("区间[" & x1 & "," & x2 &"]" & "最大值为" & t & chr(13) & "区间[" & x2 & "," & x3 &"]" & "最大值为" &s ) end su