Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:13:09+00:00 2026-06-16T00:13:09+00:00

Imports System.IO Imports System Public Class Form1 Private Class movie Public name As String

  • 0
Imports System.IO
Imports System

Public Class Form1

    Private Class movie
        Public name As String
        Public actors() As String
        Public year As String
        Public country As String
        Public votes As String

    End Class

    Private movies(0) As movie
    Private fs As FileStream
    Private input As StreamReader

    Private Sub LoadToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadToolStripMenuItem.Click
        OpenFileDialog1.ShowDialog()
        Dim i As Integer = 0

        Dim currentmv As New movie
        Dim reader As String()


        If File.Exists(OpenFileDialog1.FileName) Then

            lblPath.Text = OpenFileDialog1.FileName
            Dim iFile As New StreamReader(lblPath.Text)

            While Not iFile.EndOfStream

                reader = iFile.ReadLine.Split(";")

                currentmv.name = reader(0)
                currentmv.actors = reader(1).Split(",")
                currentmv.year = reader(2)
                currentmv.country = reader(3)
                currentmv.votes = reader(4)

                lbMovies.Items.Add(currentmv.name)

                movies(i) = currentmv

                i = i + 1
                ReDim movies(i)

            End While
        End If

    End Sub

    Private Sub lbMovies_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lbMovies.SelectedIndexChanged
        Dim i As Integer

        For i = 0 To movies(lbMovies.SelectedIndex).actors.Length

            lbActors.Items.Add(movies(lbMovies.SelectedIndex).actors(i))

        Next

    End Sub
End Class

Problem strikes when I request the length. It says it’s a null reference, but I cannot see any mistake in this. Is there an issue when I request the length of the array in an array of objects?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:13:10+00:00Added an answer on June 16, 2026 at 12:13 am

    Try

    ReDim Preserve movies(i)
    

    IIRC ReDim will initialize all elements to Nothing without Preserve.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using this in VB 2010: Imports System.Text.RegularExpressions Public Class Form1 Private Sub Button1_Click(ByVal sender
Imports System Imports System.Windows.Forms Class MyButtonClass Inherits Form Private mrButton As Button Public Sub
Here is my code: Imports System.Data.OleDb Imports System.Drawing.Printing Namespace Print Public Class Form1 Inherits
Imports System.Data.SqlClient Public Class Form3 Private cs As New SqlConnection(Data Source=HUSAIN-PC;Initial Catalog=final1;Integrated Security=True) Private
Imports SpeechLib Public Class Form1 Public vox = CreateObject(sapi.spvoice) Private Sub cmdSpeak_Click(ByVal sender As
Imports System.Net Imports System.IO Public Class Form1 Public Function GetHTML(ByVal url As Uri) As
import java.lang.System; public class Splitter{ public static void main(String args[]){ String path_separator = Path
import java.lang.Math; public class NewtonIteration { public static void main(String[] args) { System.out.print(rootNofX(2,9)); }
This is my code for connection: Imports System.Data.SqlClient Public Class frm_edit_patient Dim con As
I have this class that contains vars for db connection; Imports Microsoft.VisualBasic Imports System.Data.SqlClient

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.