1. 如何使用一个对话框获取用户的信息:First Name, Last Name, Age, 并将这些信息添加一个列表框中。如:”Tom Smith 15”
要求:
a) 如果用户输入的信息不全或者有明显的错误,能够进行基本的验证, 并让用户继续输入。
b) 用户输入信息期间,对话框不能关闭,直至用户将信息输入完毕。
c) 对话框采用Input Box,而不是自定义窗体。

解决方案 »

  1.   

    dim strtmp as string, arr() as stringdo
    strtmp = inputbox("Please input your First Name, Last Name, Age (separate by comma):", "Input Please")
    if strtmp = "" then exit sub  'inputbox canceled by userarr = split(strtmp)if ubound(arr) = 2 then
        if isnumeric(trim(arr(2))) and len(trim(arr(0))) and len(arr(1)) then exit do
    end if
    looplist1.additem trim(arr(0)) & vbtab & trim(arr(1)) & vbtab & trim(arr(2))
      

  2.   

    一个简单的方法就是在InputBox输入框中,用特点字符分割数据比如“First Name, Last Name, Age”,然后使用Split方法提取就行判断。
    复杂的方法就是使用API改造InputBox。