private r(99)private function find(byval str as double) as integer if r(0) = "" then randomize for i = 0 to ubound(r) r(i) = int(rnd * 100) next i end if for i = 0 to ubound(r) if r(i) = cdbl(str) then find = i exit function end if next i find = -1end functionprivate sub command1_click() dim i as integer i = find(inputbox("请输入一个数")) if i <> -1 then msgbox "恭喜你,猜中了!" & vbcrlf & "答案就在数组r(" & i & ")" & "中", vb**rmation else msgbox "错误!", vbcritical end ifend sub 20210311