C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Error gives in Array of control....


Posted Date: 12 Oct 2008      Total Responses: 3

Posted By: nilesh bahirshet       Member Level: Gold     Points: 1


Error shows in while creating array of user control.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim i As Integer
Dim lablearray(5) As Label
For i = 0 To 5
lablearray(i).Text = "xyz"
Next

End Sub

Its give an error as Object refrenece

"Object reference not set to an instance of an object"

what should I do ?




Responses

Author: Meetu Choudhary    13 Oct 2008Member Level: GoldRating:     Points: 3
please make use of new keyword and then see the results if it doesn't work out let me know

--
Thanks and Regards
Meetu Choudhary
-
please rate the post if it helps you


Author: senthil    13 Oct 2008Member Level: GoldRating:     Points: 2
lablearray(i).Text = "xyz"

This code modify to below code:

lablearray(i)= "xyz"


Hope this is help for U...


Author: Saravanan S    13 Oct 2008Member Level: SilverRating:     Points: 4
Hi Nilesh,

you can initialize the lable before accesssing the label. So you can changes your code as follows.

Dim i As Integer
Dim lablearray(5) As Label
For i = 0 To 5
lablearray(i) = New Label()
lablearray(i).Text = "xyz"
Next

Thanks & Regards
Saravanan.S



Post Reply
You must Sign In to post a response.
Next : Form Alignment query . .
Previous : how to resize the controls and forms for all monitor size in vb.net 2005
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use