Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ItemTypes' is not accessible in this context because it is 'Privat

Reply
Thread Tools

ItemTypes' is not accessible in this context because it is 'Privat

 
 
=?Utf-8?B?UGF0cmljay5PLklnZQ==?=
Guest
Posts: n/a
 
      10-05-2004
Hi,
I declared ItemTypes as:-
Dim ItemTypes As New ArrayList
Outside the Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load and have a function that refs it:-
Function SetIndex(ByVal TheItem As String)
Dim i As Integer
For i = 0 To ItemTypes.Count - 1
If TheItem = ItemTypes(i) Then
Return i
End If
Next
End Function
WHat could cause THIS ERROR?
Any ideas!


 
Reply With Quote
 
 
 
 
Martin Dechev
Guest
Posts: n/a
 
      10-05-2004
Hi,

See inline:

"Patrick.O.Ige" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> I declared ItemTypes as:-
> Dim ItemTypes As New ArrayList
> Outside the Private Sub Page_Load(ByVal sender As System.Object, ByVal e

As

Is it *outside* or *inside*? If it is outside, setting a accessible level of
protected is most appropriate (eg: Protected ItemTypes As New ArrayList).

> System.EventArgs) Handles MyBase.Load and have a function that refs it:-
> Function SetIndex(ByVal TheItem As String)
> Dim i As Integer
> For i = 0 To ItemTypes.Count - 1
> If TheItem = ItemTypes(i) Then
> Return i
> End If
> Next
> End Function


This code will not compile - it will give "Not all code paths return value"
compilation error. Also, note that there is an instance method on the
ArrayList class that does what your function does - it is called IndexOf.
See:

http://msdn.microsoft.com/library/en...dexOfTopic.asp

So your function will be reduced to:

Function SetIndex(ByVal TheItem As String)
Return ItemTypes.IndexOf(TheItem)
End Function

Another thing - more appropriate name is GetIndex instead of SetIndex

> WHat could cause THIS ERROR?
> Any ideas!



Hope this helps
Martin


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual directory error: "directory does not exist or is not accessible because of security settings" Dave ASP .Net 1 10-24-2005 02:05 AM
Error When using Crystal Reports: 'C' is not accessible in this context because it is 'Private'. Richard ASP .Net 1 07-27-2004 07:03 AM
'ASP.Test_ascx.UserName' is not accessible in this context because it is 'Protected'. Murphy ASP .Net Web Controls 2 04-26-2004 01:00 AM
is not accessible in this context because it is 'Protected' Murphy ASP .Net 6 04-19-2004 11:44 PM
ProcessModelConfig' is not accessible in this context because it is 'Private' Jack Wright ASP .Net 3 01-05-2004 03:58 PM



Advertisments