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 8647427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:04:06+00:00 2026-06-12T13:04:06+00:00

Module globalVariable Public tblScItem As New DataTable Public tempArray() Public index As Integer Public

  • 0
Module globalVariable

    Public tblScItem As New DataTable
    Public tempArray()
    Public index As Integer
    Public stringArr() As String

End Module

Private Sub txtQty_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtQty.TextChanged

    stringArr = New String() {"", txtItem.Text, Form2.cbGondola.SelectedItem, txtQty.Text, DateTime.Now, Form1.txtLoginId.Text}

    If txtItem.Text <> Nothing And txtQty.Text <> Nothing Then

        index = 0

        tempArray(index) = stringArr

        tblScItem.Rows.Add(tempArray)

        index += 1

    End If

End Sub

My program is a stock take program which works in a way that when the quantity of the item is entered, it will display in a datagrid and at the same time, store in an array. After the entire transaction is done, the entire array is exported to a txt file.

I have declared an array stringArr to store all the details of the an item. Then, i used a tempArray to store each item (which contains all the details in stringArr in the individual index of the tempArray.

Example: 
tempArray(0) = 'details of item 1 obtained from stringArr
tempArray(1) = 'details of item 2 obtained from stringArr
and so on

However, i kept getting ‘object is not set to an instance of an object’ after the quantity is entered.

Anyone know why? I’m in need of help.

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-12T13:04:07+00:00Added an answer on June 12, 2026 at 1:04 pm

    You are getting the error message because you haven’t initialised the tempArray variable. It’s just a reference to an array, but it doesn’t have an array to reference.

    However, you are trying to put an array in an array, but the DataRowCollection.Add method takes an array, not an array of arrays.

    Just use the stringArr variable:

    Private Sub txtQty_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtQty.TextChanged
    
      stringArr = New String() {"", txtItem.Text, Form2.cbGondola.SelectedItem, txtQty.Text, DateTime.Now, Form1.txtLoginId.Text}
    
      If txtItem.Text <> "" And txtQty.Text <> "" Then
    
        tblScItem.Rows.Add(stringArr)
    
      End If
    
    End Sub
    

    Note that the Text property of a control is never Empty, you should check if it is an empty string.

    If you want to add the rows to a collection other than the DataTable, you wouldn’t use an array, as it’s not resizable. You would use a List(Of String()):

    Public tempList As new List(Of String())
    
    Private Sub txtQty_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtQty.TextChanged
    
      stringArr = New String() {"", txtItem.Text, Form2.cbGondola.SelectedItem, txtQty.Text, DateTime.Now, Form1.txtLoginId.Text}
    
      If txtItem.Text <> "" And txtQty.Text <> "" Then
    
        tempList.Add(stringArr)
    
        tblScItem.Rows.Add(stringArr)
    
      End If
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Module Module1 Public cccounter = 9 End Module Public Class frmNim Private Sub btnSelect_Click(sender
I have this short piece of code Public n As Integer Public Sub Foo()
module Test def self.model_method puts this is a module method end end class A
module MyModule def my_method; 'hello'; end end class MyClass class << self include MyModule
module Superpower # instance method def turn_invisible ... end # module method def Superpower.turn_into_toad
module M def f=(x) @f= x end def f @f end end class A
I have a dictionary called fsdata at module level (like a global variable). The
Module: ./FOO/BAR/Foobar.pm use strict; use warnings; package Foobar; our($VERSION , @ISA , @EXPORT ,
plotting module def plotGraph(X,Y): fignum = random.randint(0,sys.maxint) plt.figure(fignum) ### Plotting arrangements ### return fignum
Three module exists. Cfg, Main and Component Cfg.py value = 0 Component.py import Cfg

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.