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