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

Recommended Answers

Hi Alfredo,

Great that you found your own problem.
Mark your thread as solved.

Jump to Post

All 2 Replies

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

Hi Alfredo,

Great that you found your own problem.
Mark your thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.