473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

System.NullReferenceException Error

I am trying to place an strings into an array of strings I am
declaring as
Dim Fields() As String

I have another variable im doing the same thing with and it works.

Public Shared Operations() As String

This is the error I am getting

System.NullReferenceException: Object reference not set to an instance
of an object.

Here is my code
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WebForm1 As System.Web.UI.HtmlControls.HtmlForm
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents DropDownList1 As
System.Web.UI.WebControls.DropDownList
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents ListBox1 As System.Web.UI.WebControls.ListBox
Protected WithEvents Repeater1 As
System.Web.UI.WebControls.Repeater
Protected WithEvents DataGrid1 As
System.Web.UI.WebControls.DataGrid
Protected WithEvents DataList1 As
System.Web.UI.WebControls.DataList
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Public Shared Operations() As String
Dim FieldList As ClientResearch.Research
Dim Fields() As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
FieldList.GetFieldListing(FEID, CID, UserName, Password,
Fields)
Try

If Not Fields Is Nothing Then
Dim txtBoxes(UBound(Fields)) As
System.Web.UI.WebControls.TextBox
Dim j As Int32
Dim k As Int32 = 0
For j = 0 To UBound(Fields)
txtBoxes(j) = New TextBox()
txtBoxes(j).ID = Fields(j)
txtBoxes(j).Text = "Field " & Fields(j)
txtBoxes(j).Style("Position") = "Absolute"
txtBoxes(j).Style("Top") = "100px"
txtBoxes(j).Style("Left") = "100px"
WebForm1.Controls.Add(txtBoxes(j))
k = k + 5
Next j
End If
If Not Page.IsPostBack Then
If OperationsList() = "" Then
Dim Operations(0)
Operations(0) = "No Operations Found"
DropDownList1.Items.Add(Operations(0))
Else
Dim i As Integer = 0
Operations = OperationsList.Split(",")
i = 0
For i = 0 To UBound(Operations)
DropDownList1.Items.Add(Operations(i))
Next
End If
End If

Catch ErrorMessage As Exception

TextBox1.Text = ErrorMessage.Message() &
ErrorMessage.Source

Finally

End Try
End Sub

It doesn't matter what I do, but i cannot get past this point.

I have even tried to Dim the array as Dim Fields(0) As String
and then setting Fields(0) = "Test" and during debug it Fails on this
line.
I cant find anything in the newsgroups except Dim Fields(-1) As String
but that does not work. Tried setting it to nothing, didnt work. The
Function GetFieldListing does not get called, it fails on that line.
If anyone can help I would greatly appreciate it.

Thank you in advance,

Eric
Nov 12 '05 #1
0 749

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

Similar topics

7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
0
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
1
by: msnews.microsoft.com | last post by:
I'm trying to fill an array of objects but when I add the first object I get a NullReferenceException. ----------------------------------------------------------------------------...
4
by: Terry Mulvany | last post by:
I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all my pages inherit from. I need to set some properties (either in the OnInit or constructor) based on a potential...
4
by: ven | last post by:
How must i declare my variables to have this code work. I get system.nullreferenceexception every time i click button to add data to datatable here below is my code : Dim wykszt as...
2
by: sxiao | last post by:
Hi, there I got a NullReferenceException when there are more than one users trying to open the same page at the same time. The senerio is: Two users logged into the web application using the...
6
by: William Mild | last post by:
I must be getting brain fried. I can't see the error. Create a new web form with the following code begind: Public Class test Inherits System.Web.UI.Page Public Class ReportCardData ...
0
by: sqlguy | last post by:
I am using a vendor package written in .net 2.0 C#. They say it works well, and that I may have a configuration issue. The error I am getting is shown below. Searching ms and google, it seems...
2
by: justmvb | last post by:
Error: EventType clr20r3, P1 redsmsservice.exe, P2 1.0.0.0, P3 48c0e7d0, P4 gsmcommunication, P5 1.10.0.0, P6 44d2c55f, P7 96, P8 3b, P9 system.nullreferenceexception, P10 NIL. System: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.