Hi guys! I am having trouble debugging these codes. I tried putting "New" keyword in declaring the image variables. Can anyone help me please? I'm creating an RPG game

Dim picf(), picl(), picr(), picb() As Image 'Main problem: when I put "New" keyword it says I                       'cannot use it when declaring an array
    Private Sub frmWalk_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Right Then
            num = num + 1
            PictureBox1.Image = picf(num)
            If num = 3 Then
                num = 0
            End If
        End If
    End Sub
    Private Sub frmWalk_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        picf(1) = f1.Image 'this is problem
        picf(2) = f2.Image
        picf(3) = f3.Image

Edited 5 Years Ago by alfredo11: n/a

Hi guys! I am having trouble debugging these codes. I tried putting "New" keyword in declaring the image variables. Can anyone help me please? I'm creating an RPG game

Dim picf(), picl(), picr(), picb() As Image 'Main problem: when I put "New" keyword it says I                       'cannot use it when declaring an array
    Private Sub frmWalk_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Right Then
            num = num + 1
            PictureBox1.Image = picf(num)
            If num = 3 Then
                num = 0
            End If
        End If
    End Sub
    Private Sub frmWalk_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        picf(1) = f1.Image 'this is problem
        picf(2) = f2.Image
        picf(3) = f3.Image

OK I answered my own problem. Thank you

This article has been dead for over six months. Start a new discussion instead.