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

  • Home
  • SEARCH
  • 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 7946367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:07:52+00:00 2026-06-04T01:07:52+00:00

I am working on a VB Windows Form and I have a question here

  • 0

I am working on a VB Windows Form and I have a question here about initialize an array (friend variable)

I have a BookInfo class as following:

Public Class BookInfoForm
  Friend _books() As BookInfo
  ...
EndClass

And in my main form, I want to initialize this _books array to be size 4.

What I have tried was:

_bookInfoForm._books(4) = New BookInfo

But this didn’t work and it thrown an exception says

Object reference not set to an instance of an object.

I am wondering how I can have the array initialized to size 4. Anyone can help me with this?

Thank you

  • 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-04T01:07:54+00:00Added an answer on June 4, 2026 at 1:07 am

    First of all you need to initialize your BookInfoForm class, then use Redim to resize your array

    Dim BookInfo As New BookInfoForm
    Redim BookInfo._books(4)
    

    The Redim could resize your array but also clear all data in the array, if you want to keep those data while resizing your array, then you need to use Preserve after Redim

    Redim Preserve BookInfo._books(4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a WindowsForm project and in my form I have a DataGridView
I m working on windows form application. I need to show amount in words
I am working on a windows form project and having some problem with UserControl
I'm working with a windows form application in C#. I'm using a socket client
I'm working with a windows form application in C#. I'm using a socket client
I have modified a working Windows service that had always been starting beforehand. After
I am working on Windows Azure. I followed some tutorial about how to store
Currently I am working with: C# Windows forms application I currently have a problem
I want to do the following (c#) I have a Form,let's call Form1 Form1
can I have a question about how to redirect the page after user invite

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.