473,387 Members | 1,812 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,387 software developers and data experts.

Variable is used before it has been assigned

i have write code in that updates details of student and then present it in a
different panel i n the same. however a recieve object reference not set to
an instance of an object.

Can someone please help me to correct it. below is the sub where the error
is trapped.

Sub UpdateStudent_Click(ByVal sender As Object, ByVal e As EventArgs)
If Page.IsValid = True Then

Dim tbTitle As TextBox
Dim tbStatus As TextBox
Dim tbSurname As TextBox
Dim tbFirstname As TextBox
Dim tbHouseNumber As TextBox
Dim tbStreet As TextBox
Dim tbTown As TextBox
Dim tbCounty As TextBox
Dim tbCountry As TextBox
Dim tbPostCode As TextBox
Dim tbDateOfBirth As TextBox
Dim tbNationality As TextBox
Dim tbTelephone As TextBox
Dim tbMobile As TextBox
Dim tbEmail As TextBox
Dim tbFax As TextBox
Dim tbCourseID As TextBox
Dim tbDateEnroled As TextBox
Dim tbComment As TextBox

Dim item As DataListItem
For Each item In UpdateDataList.Items
tbTitle = item.FindControl("Title")
tbStatus = item.FindControl("Status")
tbSurname = item.FindControl("Surname")
tbFirstname = item.FindControl("Firstname")
tbHouseNumber = item.FindControl("HouseNumber")
tbStreet = item.FindControl("Street")
tbTown = item.FindControl("Town")
tbCounty = item.FindControl("County")
tbCountry = item.FindControl("Country")
tbPostCode = item.FindControl("Postcode")
tbDateOfBirth = item.FindControl("DateOfBirth")
tbNationality = item.FindControl("Nationality")
tbTelephone = item.FindControl("Telephone")
tbMobile = item.FindControl("Mobile")
tbEmail = item.FindControl("email")
tbFax = item.FindControl("Fax")
tbCourseID = item.FindControl("CourseID")
tbDateEnroled = item.FindControl("DateEnroled")
tbComment = item.FindControl("Comment")
Next item

Dim StudentID As Integer = CInt(ViewState("StudentID"))
Dim UpdateDetails As New StudentDB
UpdateDetails.UpdateStudentDetails(StudentID, tbTitle.Text,
tbSurname.Text, tbFirstname.Text, tbHouseNumber.Text, tbStreet.Text,
tbTown.Text, tbCounty.Text, tbCountry.Text, tbPostCode.Text,
tbDateOfBirth.Text, tbNationality.Text, tbTelephone.Text, tbMobile.Text,
tbEmail.Text, tbFax.Text, tbCourseID.Text, tbDateEnroled.Text, tbStatus.Text,
tbComment.Text)
BindViewPanel()
End If
End Sub
Jan 8 '06 #1
3 1308
I can't tell you how helpful it would be if you provided the exact line
where the error is at.

It might be because Items will hit the HeaderTemplate and FooterTemplate, in
which case there aren't any of the textbox you expect.

Karl

--
http://www.openmymind.net/

"paapa21" <pa*****@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
i have write code in that updates details of student and then present it in
a
different panel i n the same. however a recieve object reference not set
to
an instance of an object.

Can someone please help me to correct it. below is the sub where the error
is trapped.

Sub UpdateStudent_Click(ByVal sender As Object, ByVal e As EventArgs)
If Page.IsValid = True Then

Dim tbTitle As TextBox
Dim tbStatus As TextBox
Dim tbSurname As TextBox
Dim tbFirstname As TextBox
Dim tbHouseNumber As TextBox
Dim tbStreet As TextBox
Dim tbTown As TextBox
Dim tbCounty As TextBox
Dim tbCountry As TextBox
Dim tbPostCode As TextBox
Dim tbDateOfBirth As TextBox
Dim tbNationality As TextBox
Dim tbTelephone As TextBox
Dim tbMobile As TextBox
Dim tbEmail As TextBox
Dim tbFax As TextBox
Dim tbCourseID As TextBox
Dim tbDateEnroled As TextBox
Dim tbComment As TextBox

Dim item As DataListItem
For Each item In UpdateDataList.Items
tbTitle = item.FindControl("Title")
tbStatus = item.FindControl("Status")
tbSurname = item.FindControl("Surname")
tbFirstname = item.FindControl("Firstname")
tbHouseNumber = item.FindControl("HouseNumber")
tbStreet = item.FindControl("Street")
tbTown = item.FindControl("Town")
tbCounty = item.FindControl("County")
tbCountry = item.FindControl("Country")
tbPostCode = item.FindControl("Postcode")
tbDateOfBirth = item.FindControl("DateOfBirth")
tbNationality = item.FindControl("Nationality")
tbTelephone = item.FindControl("Telephone")
tbMobile = item.FindControl("Mobile")
tbEmail = item.FindControl("email")
tbFax = item.FindControl("Fax")
tbCourseID = item.FindControl("CourseID")
tbDateEnroled = item.FindControl("DateEnroled")
tbComment = item.FindControl("Comment")
Next item

Dim StudentID As Integer = CInt(ViewState("StudentID"))
Dim UpdateDetails As New StudentDB
UpdateDetails.UpdateStudentDetails(StudentID, tbTitle.Text,
tbSurname.Text, tbFirstname.Text, tbHouseNumber.Text, tbStreet.Text,
tbTown.Text, tbCounty.Text, tbCountry.Text, tbPostCode.Text,
tbDateOfBirth.Text, tbNationality.Text, tbTelephone.Text, tbMobile.Text,
tbEmail.Text, tbFax.Text, tbCourseID.Text, tbDateEnroled.Text,
tbStatus.Text,
tbComment.Text)
BindViewPanel()
End If
End Sub

Jan 8 '06 #2
Thanks Karl. the exact line where i do get the error is:

UpdateDetails.UpdateStudentDetails(StudentID, tbTitle.Text,
tbSurname.Text.....tbComment.text)

in the code posted. This use to work well without any error when i send it
to a different page to display it result using request.redirect(url). Now
that i result to appear in a different panel in the same page it give me this
error. I need help

"Karl Seguin [MVP]" wrote:
I can't tell you how helpful it would be if you provided the exact line
where the error is at.

It might be because Items will hit the HeaderTemplate and FooterTemplate, in
which case there aren't any of the textbox you expect.

Karl

--
http://www.openmymind.net/

"paapa21" <pa*****@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
i have write code in that updates details of student and then present it in
a
different panel i n the same. however a recieve object reference not set
to
an instance of an object.

Can someone please help me to correct it. below is the sub where the error
is trapped.

Sub UpdateStudent_Click(ByVal sender As Object, ByVal e As EventArgs)
If Page.IsValid = True Then

Dim tbTitle As TextBox
Dim tbStatus As TextBox
Dim tbSurname As TextBox
Dim tbFirstname As TextBox
Dim tbHouseNumber As TextBox
Dim tbStreet As TextBox
Dim tbTown As TextBox
Dim tbCounty As TextBox
Dim tbCountry As TextBox
Dim tbPostCode As TextBox
Dim tbDateOfBirth As TextBox
Dim tbNationality As TextBox
Dim tbTelephone As TextBox
Dim tbMobile As TextBox
Dim tbEmail As TextBox
Dim tbFax As TextBox
Dim tbCourseID As TextBox
Dim tbDateEnroled As TextBox
Dim tbComment As TextBox

Dim item As DataListItem
For Each item In UpdateDataList.Items
tbTitle = item.FindControl("Title")
tbStatus = item.FindControl("Status")
tbSurname = item.FindControl("Surname")
tbFirstname = item.FindControl("Firstname")
tbHouseNumber = item.FindControl("HouseNumber")
tbStreet = item.FindControl("Street")
tbTown = item.FindControl("Town")
tbCounty = item.FindControl("County")
tbCountry = item.FindControl("Country")
tbPostCode = item.FindControl("Postcode")
tbDateOfBirth = item.FindControl("DateOfBirth")
tbNationality = item.FindControl("Nationality")
tbTelephone = item.FindControl("Telephone")
tbMobile = item.FindControl("Mobile")
tbEmail = item.FindControl("email")
tbFax = item.FindControl("Fax")
tbCourseID = item.FindControl("CourseID")
tbDateEnroled = item.FindControl("DateEnroled")
tbComment = item.FindControl("Comment")
Next item

Dim StudentID As Integer = CInt(ViewState("StudentID"))
Dim UpdateDetails As New StudentDB
UpdateDetails.UpdateStudentDetails(StudentID, tbTitle.Text,
tbSurname.Text, tbFirstname.Text, tbHouseNumber.Text, tbStreet.Text,
tbTown.Text, tbCounty.Text, tbCountry.Text, tbPostCode.Text,
tbDateOfBirth.Text, tbNationality.Text, tbTelephone.Text, tbMobile.Text,
tbEmail.Text, tbFax.Text, tbCourseID.Text, tbDateEnroled.Text,
tbStatus.Text,
tbComment.Text)
BindViewPanel()
End If
End Sub


Jan 8 '06 #3
Well, you'll need to debug your code. If findControl fails, it returns
null...so it could be any of them...a simple typo perhaps. If you have
visual studio, add a break point to the code and hit f5..then step through
it...

Karl
--
http://www.openmymind.net/

"paapa21" <pa*****@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
Thanks Karl. the exact line where i do get the error is:

UpdateDetails.UpdateStudentDetails(StudentID, tbTitle.Text,
tbSurname.Text.....tbComment.text)

in the code posted. This use to work well without any error when i send it
to a different page to display it result using request.redirect(url). Now
that i result to appear in a different panel in the same page it give me
this
error. I need help

"Karl Seguin [MVP]" wrote:
I can't tell you how helpful it would be if you provided the exact line
where the error is at.

It might be because Items will hit the HeaderTemplate and FooterTemplate,
in
which case there aren't any of the textbox you expect.

Karl

--
http://www.openmymind.net/

"paapa21" <pa*****@discussions.microsoft.com> wrote in message
news:C4**********************************@microsof t.com...
>i have write code in that updates details of student and then present it
>in
>a
> different panel i n the same. however a recieve object reference not
> set
> to
> an instance of an object.
>
> Can someone please help me to correct it. below is the sub where the
> error
> is trapped.
>
> Sub UpdateStudent_Click(ByVal sender As Object, ByVal e As EventArgs)
> If Page.IsValid = True Then
>
> Dim tbTitle As TextBox
> Dim tbStatus As TextBox
> Dim tbSurname As TextBox
> Dim tbFirstname As TextBox
> Dim tbHouseNumber As TextBox
> Dim tbStreet As TextBox
> Dim tbTown As TextBox
> Dim tbCounty As TextBox
> Dim tbCountry As TextBox
> Dim tbPostCode As TextBox
> Dim tbDateOfBirth As TextBox
> Dim tbNationality As TextBox
> Dim tbTelephone As TextBox
> Dim tbMobile As TextBox
> Dim tbEmail As TextBox
> Dim tbFax As TextBox
> Dim tbCourseID As TextBox
> Dim tbDateEnroled As TextBox
> Dim tbComment As TextBox
>
> Dim item As DataListItem
> For Each item In UpdateDataList.Items
> tbTitle = item.FindControl("Title")
> tbStatus = item.FindControl("Status")
> tbSurname = item.FindControl("Surname")
> tbFirstname = item.FindControl("Firstname")
> tbHouseNumber = item.FindControl("HouseNumber")
> tbStreet = item.FindControl("Street")
> tbTown = item.FindControl("Town")
> tbCounty = item.FindControl("County")
> tbCountry = item.FindControl("Country")
> tbPostCode = item.FindControl("Postcode")
> tbDateOfBirth = item.FindControl("DateOfBirth")
> tbNationality = item.FindControl("Nationality")
> tbTelephone = item.FindControl("Telephone")
> tbMobile = item.FindControl("Mobile")
> tbEmail = item.FindControl("email")
> tbFax = item.FindControl("Fax")
> tbCourseID = item.FindControl("CourseID")
> tbDateEnroled = item.FindControl("DateEnroled")
> tbComment = item.FindControl("Comment")
> Next item
>
> Dim StudentID As Integer = CInt(ViewState("StudentID"))
> Dim UpdateDetails As New StudentDB
> UpdateDetails.UpdateStudentDetails(StudentID, tbTitle.Text,
> tbSurname.Text, tbFirstname.Text, tbHouseNumber.Text, tbStreet.Text,
> tbTown.Text, tbCounty.Text, tbCountry.Text, tbPostCode.Text,
> tbDateOfBirth.Text, tbNationality.Text, tbTelephone.Text,
> tbMobile.Text,
> tbEmail.Text, tbFax.Text, tbCourseID.Text, tbDateEnroled.Text,
> tbStatus.Text,
> tbComment.Text)
> BindViewPanel()
> End If
> End Sub


Jan 8 '06 #4

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

Similar topics

6
by: Oplec | last post by:
Hi, I thought that I understood how C++ allows for the declaration and defining of variables within an if() statement and how the declared variable can be used until the end of the major if()...
12
by: Ivan Marsh | last post by:
Hey Folks, Anyone know how to test for the existance of a variable in javascript? I'm looking for the equivalent of IsSet() from PHP. I'm having trouble finding it. thx --
7
by: Donna Hawkins | last post by:
I want to use javascript to redirect to a URL which has been passed as a variable (in php). I have searched but cannot find any solution. I think this code is a basic redirect: <script...
7
by: Klaus Johannes Rusch | last post by:
Is the following code valid and supported by current implementations? function somename() { this.show = function () { document.write("somename called") } } var somename = new somename();...
14
by: sathya_me | last post by:
Dear clc, I have a variable void *a; Since variable "a" can be assigned (point to) any type and also any type can be assigned to "a" (i.e means "a" = any typed variable; any typed variable =...
23
by: Russ Chinoy | last post by:
Hi, This may be a totally newbie question, but I'm stumped. If I have a function such as: function DoSomething(strVarName) { ..... }
7
by: **Developer** | last post by:
Public Shared Sub junk... Dim PF2 As Wnd.PARAFORMAT2 PF2.cbSize = Marshal.SizeOf(PF2) 'ERROR HERE PF2.dwMask = Wnd.PFM_LINESPACING ....snip
9
by: krollenhagen | last post by:
Hello- Let me start out by saying that I am new to .net and was only a hobby vb6 programmer. I am getting the warning: "Variable 'arrOutputData' is used before it has been assigned a value....
22
by: Laura T. | last post by:
In the following example, c# 2.0 compiler says that a3 and ret are used before assigned. as far as I can see, definite assignment is made. If I add finally { ret = true; a3 = "b3";
5
by: rohdej | last post by:
Hello - I have been all over the web and found a few posts that are somewhat related to what I'm trying to do, but none that provided me a concise answer. I want to prompt the user to input the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.