在QTP中如何将字符串存储在一个数组中,将数字存储在另一个数组中

时间:2015-04-11 07:50:01

标签: qtp

在QTP中从用户获取10个输入,如果传递输入是字符串存储在一个数组中,如果是数字则将其存储在另一个数组中

1 个答案:

答案 0 :(得分:0)

size_of_num=0
size_of_nonnum=0
Dim Num()
Dim Nonnum()
For i=1 to 10
val = InputBox ("Enter a number or a string", "User Input")
msgbox val
If IsNumeric(val) Then
    msgbox "numeric"
    Redim Preserve Num(size_of_num)
    Num(size_of_num) = val
    msgbox "Num("& size_of_num &") -->" & Num(size_of_num)
    size_of_num=size_of_num+1
else
    msgbox "string"
    Redim Preserve Nonnum(size_of_nonnum)
    Nonnum(size_of_nonnum) = val
    msgbox "Nonnum("& size_of_nonnum &") -->" & Nonnum(size_of_nonnum)
    size_of_nonnum=size_of_nonnum+1
End If
Next

试试这个