tags:

views:

39

answers:

1

I'm using Visual Basic 2008EE and I have a problem with this loop:

If x = CType("new", Primitive) Then
        TextWindow.Write("How many new users would you like to add?     ")
        k = TextWindow.ReadNumber()
        For mt = 1 To k
            NewUserEntry()
        Next

and i get this error:

"type of 'mt' is ambigious because the loop bounds and the step clause do not convert to the same type"

I appreciate any help.

+2  A: 

The return type of ReadNumber (or more accurately, the type of k variable) is probably not an Integer. When the compiler wants to infer the type of the mt, it fails since k, which is specified as the loop bound has one type (probably something like Double) and the loop step (implicitly the integer constant 1) has the type Integer. The compiler will not automatically assume the type of mt since the two don't match.

For mt As Integer = 1 To k
     NewUserEntry()
Next
Mehrdad Afshari