473,466 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Array Error

Hey guys, I am getting this error:

An unhandled exception of type 'System.NullReferenceException' occurred
in microsoft.visualbasic.dll

Additional information: Object Variable or With block variable not set.

Here is my code

Private Sub butSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butSave.Click
Dim myDatabase As New Database(Me)
Dim myArray As Array

myArray(0) = txtCompany.Text
myArray(1) = txtFeeder.Text
myArray(2) = txtAddress1.Text
myArray(3) = txtAddress2.Text
myArray(4) = txtCity.Text
myArray(5) = txtState.Text
myArray(6) = txtZip.Text

myDatabase.insertData("Customers", myArray)
End Sub

Any ideas why I am getting this error?

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
2 1042
Cor
Hi Ivan,

Two things,

put in top of your program "Option Strict On" then you see the errors
use the arraylist instead of the array,

I expect looking to the rest of your code that you than can find the rest
yourself
(I think it is not one error, the next will be if you solve just one).

I hope this helps a little bit?

Cor
An unhandled exception of type 'System.NullReferenceException' occurred
in microsoft.visualbasic.dll
Additional information: Object Variable or With block variable not set.

Here is my code

Private Sub butSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles butSave.Click
Dim myDatabase As New Database(Me)
Dim myArray As Array

myArray(0) = txtCompany.Text
myArray(1) = txtFeeder.Text
myArray(2) = txtAddress1.Text
myArray(3) = txtAddress2.Text
myArray(4) = txtCity.Text
myArray(5) = txtState.Text
myArray(6) = txtZip.Text

myDatabase.insertData("Customers", myArray)
End Sub

Nov 20 '05 #2
"Ivan Weiss" <iv*****@optonline.net> schrieb
Hey guys, I am getting this error:

An unhandled exception of type 'System.NullReferenceException'
occurred in microsoft.visualbasic.dll

Additional information: Object Variable or With block variable not
set.

Here is my code

Private Sub butSave_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles butSave.Click
Dim myDatabase As New Database(Me)
Dim myArray As Array

myArray(0) = txtCompany.Text
myArray(1) = txtFeeder.Text
myArray(2) = txtAddress1.Text
myArray(3) = txtAddress2.Text
myArray(4) = txtCity.Text
myArray(5) = txtState.Text
myArray(6) = txtZip.Text

myDatabase.insertData("Customers", myArray)
End Sub

Any ideas why I am getting this error?


You did not create an array. I'd declare it this way:

Redim myArray(6) 'instead of myArray as Array
If you declare it myArray as Array, you have to
1. call Array.CreateInstance to create the array
2. Use myArray.Setvalue to change the content
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Keiron Waites | last post by:
I get the following error: Notice: Array to string conversion in C:\Documents and Settings\ShepMode\Desktop\Websites\ShareMonkey.net\Web\join.php on line 11 in this code: $input =...
1
by: J. Campbell | last post by:
I have a feeling that I'm doing things all ass-backwards (again ;-), and would like some advice. What I want to do is: put some data to memory and then access that memory space as an array of...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
4
by: Robert P. | last post by:
I can easily store a one-dimensional array in viewstate ( see Test1 ) If I try storing a multi-dimensional array in the viewstate it's crapping out on me when it goes to serialize the array (not...
3
by: danbraund | last post by:
Hi everyone, I'm a long time C coder, who is coding his final year project in C++ to run under the MIT click routing system. Being fairly new to the OO side of the language, my problem is this: ...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
7
by: arnuld | last post by:
this programme gives unusual output. i am not able to find out where the semantic bug lies: /* C++ Primer - 4/e * * an example from section section 7.2.4, page 241 * STATEMENT * write a...
7
by: Christof Warlich | last post by:
Hi, the subject says it all: I need to instantiate an array of objects where each object "knows" its arrary index. So far, this is easy as long as index is not a compile-time constant: class ...
3
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.