Reputation: 89
dim rc
dim num
rc = InputBox("Enter rc")
for i=1 to rc
if(i=rc) then
WScript.echo "Equal"
end if
next
The above code does not print Equal when i enter 5 in the InputBox. Is this a issue because i and rc are of different types?
Upvotes: 2
Views: 2060
Reputation: 5471
Try this
dim rc
dim i
rc = CInt(InputBox("Enter rc"))
for i= 1 to rc
if i=rc then
MsgBox "Equal"
end if
next
Your assumption is correct. By default, InputBox returns a variant with string subtype. Hence, you need to change its type before comparison. In your case, i is of int subtype, hence I changed the return value of InputBox to int.
Upvotes: 3