-2

I'm trying to add an option to do something a set amount of times, but I couldn't get an int32 to work with it. I'm using

dim Int As Int32() For i = 0 To Int 'code Next i

Any help is appreciated. Thanks.

WireIsCool
  • 11
  • 1
  • 4
  • Could you please share a full snippet? – Mureinik Jan 26 '15 at 22:59
  • 4
    [Some tutorial for you](http://www.dotnetperls.com/for-vbnet) – Steve Jan 26 '15 at 23:12
  • Also refer to the MSDN documentation. https://msdn.microsoft.com/en-us/library/5z06z1kb.aspx – Jeremy Jan 26 '15 at 23:21
  • Well, you could start by a) not using a confusing variable name like `Int`, which can be confused with an actual data type, and b) giving your variable a value before trying to use it as the upper bound of a loop. What **specific problem** other than failing to do other than that do you have? – Ken White Jan 26 '15 at 23:24

1 Answers1

2

Besides being poorly named, with the parenthesis after Int32() you're actually declaring an Array of Int32. You probably just wanted a single Int32, in which case you should get rid of the parenthesis and also give it a value:

    Dim NumberOfTimes As Int32 = 3
    For i As Int32 = 1 To NumberOfTimes
        MessageBox.Show("Hello " & i.ToString)
    Next i
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40
  • Yeah, I realized that that was an array a while after I posted this. Sorry for the wait, and thanks for the declaration help. – WireIsCool Jan 30 '15 at 13:50