473,327 Members | 2,065 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,327 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
Jul 19 '05 #1
0 2223

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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.