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

Class item not accessible because it's private... but it's not?

I have a sub, and a class. The sub is like this:
Sub dothis()
Dim aInfoListX As New infoWrapperClass
aInfoListX.params = ReadConfig()
Dim sqlCMD As New SqlCommand
aInfoListX.sqlCmd = sqlCMD

aInfoListX.sqlConn = New
SqlClient.SqlConnection(aInfoListX.params.sqlserve r)
End Sub

Now, I have a class, with subclasses, as below. However, in the above
sub, it tells me that "aInfoLisX.params.sqlserver" is not accessible in
this context because it is private". I'm using VS 2005, vb.net. I don't
quite understand what's going on here..... Any help would be greatly
appreciated!

Public Class infoWrapperClass
Dim Item As ArrayList
Public Sub New()
Dim _Adapters As System.Management.ManagementObjectCollection =
Nothing
Dim _AdapterInfo As
System.Management.ManagementObjectCollection = Nothing
Dim _NdisReceiveErrors As
System.Management.ManagementObjectCollection = Nothing
Dim _NdisTransmitErrors As
System.Management.ManagementObjectCollection = Nothing
Dim _NdisMacOptions As
System.Management.ManagementObjectCollection = Nothing
Dim _NdisLinkSpeed As
System.Management.ManagementObjectCollection = Nothing
Dim bkGnd As New System.ComponentModel.BackgroundWorker
Dim wmiObj1 As New System.Management.ManagementObject
Dim myConfigs As New Configs

Item = New ArrayList(13)
Item.Add(_Adapters)
Item.Add(_AdapterInfo)
Item.Add(_NdisReceiveErrors)
Item.Add(_NdisTransmitErrors)
Item.Add(_NdisMacOptions)
Item.Add(_NdisLinkSpeed)
Item.Add(bkGnd)
Item.Add(myConfigs)
Item.Add(New ServerInfo)
Item.Add(wmiObj1)
Item.Add(New SqlClient.SqlCommand)
Item.Add(New nicStruct)
Item.Add(New SqlClient.SqlConnection)
End Sub
Public Property Adapters() As
System.Management.ManagementObjectCollection
Get
Return CType(Item(0),
Management.ManagementObjectCollection)
End Get
Set(ByVal value As
System.Management.ManagementObjectCollection)
Item(0) = value
End Set
End Property
Public Property AdapterInfo() As
System.Management.ManagementObjectCollection
Get
Return CType(Item(1),
Management.ManagementObjectCollection)
End Get
Set(ByVal value As
System.Management.ManagementObjectCollection)
Item(1) = value
End Set
End Property
Public Property NdisReceiveErrors() As
System.Management.ManagementObjectCollection
Get
Return CType(Item(2),
Management.ManagementObjectCollection)
End Get
Set(ByVal value As
System.Management.ManagementObjectCollection)
Item(2) = value
End Set
End Property
Public Property NdisTransmitErrors() As
System.Management.ManagementObjectCollection
Get
Return CType(Item(3),
Management.ManagementObjectCollection)
End Get
Set(ByVal value As
System.Management.ManagementObjectCollection)
Item(3) = value
End Set
End Property
Public Property NdisMacOptions() As
System.Management.ManagementObjectCollection
Get
Return CType(Item(4),
Management.ManagementObjectCollection)
End Get
Set(ByVal value As
System.Management.ManagementObjectCollection)
Item(4) = value
End Set
End Property
Public Property NdisLinkSpeed() As
System.Management.ManagementObjectCollection
Get
Return CType(Item(5),
Management.ManagementObjectCollection)
End Get
Set(ByVal value As
System.Management.ManagementObjectCollection)
Item(5) = value
End Set
End Property
Public Property bkgndWrkr() As
System.ComponentModel.BackgroundWorker
Get
Return CType(Item(6),
System.ComponentModel.BackgroundWorker)
End Get
Set(ByVal value As System.ComponentModel.BackgroundWorker)
Item(6) = value
End Set
End Property
Public Property params() As configs
Get
Return CType(Item(7), configs)
End Get
Set(ByVal value As configs)
Item(7) = value
End Set
End Property
Public Property svrInfo() As ServerInfo
Get
Return CType(Item(8), ServerInfo)
End Get
Set(ByVal value As ServerInfo)
Item(8) = value
End Set
End Property
Public Property wmiObj() As System.Management.ManagementObject
Get
Return CType(Item(9), Management.ManagementObject)
End Get
Set(ByVal value As System.Management.ManagementObject)
Item(9) = value
End Set
End Property
Public Property sqlCmd() As SqlClient.SqlCommand
Get
Return CType(Item(10), SqlClient.SqlCommand)
End Get
Set(ByVal value As SqlClient.SqlCommand)
Item(10) = value
End Set
End Property
Public Property nicInfo() As nicStruct
Get
Return CType(Item(11), nicStruct)
End Get
Set(ByVal value As nicStruct)
Item(11) = value
End Set
End Property
Public Property sqlConn() As SqlClient.SqlConnection
Get
Return CType(Item(12), SqlClient.SqlConnection)
End Get
Set(ByVal value As SqlClient.SqlConnection)
Item(12) = value
End Set
End Property
Public Class Configs
Dim logdirectory As String
Dim logfile As String
Dim errLog As String
Dim logfileops As Boolean
Dim logscreenops As Boolean
Dim userid As String
Dim password As String
Dim ldapServer As String
Dim prodSql As String
Dim testsql As String
Dim devsql As String
Dim tempFile As String
Dim log As String
Dim sqlServer As String
End Class
Public Class ServerInfo
Dim oDN As String
Dim oGUID As Guid
Dim oDOMAIN As String
Dim ostrGUID As String
Dim oNAME As String
Dim ipAddress As String
Dim oDNSHOSTNAME As String
Dim oDescription As String
Dim oOS As String
Dim oOSVersion As String
Dim oTZ As Int16
Dim oManagedBy As String
Dim oLastLogon As Date
Dim oSPMajor As Short
Dim oSPMinor As Short
Dim oCreateDate As Date
Dim oError As Boolean
Dim oElapsed As String
Dim isPartial As Boolean
Dim isUpdate As Boolean
Dim strHosts As String
Dim DNSREAD As Boolean
End Class
Public Class nicStruct
Dim CLASSGUID As String 'The Windows CLASSGUID identifier
Dim Subkey As String 'The subkey string to find the nic
values in
Dim Value As String 'The key who's value we need
Dim PNPid As String 'The PNPSHORT adapter identifier
Dim Service As String 'The driver
Dim Duplex As String 'The duplex setting found
Dim Speed As String 'The speed found (Unless set to auto)
Dim settings As String 'The result of the registry query on
the media (speed/duplex) requested
'Dim newreturn As String '?
Dim productName As String 'i.e. "HP NC7781 GIGABIT SERVER
ADAPTER"
Dim infPath As String 'What inf is the nic using?
Dim paramSubkey As String 'The subkey to fetch the
Speed/Duplex given from "settings"
Dim bError As Boolean
Dim strIndex As String
Dim netConnectionID As String 'As viewed in the Network
connections folder
End Class
End Class

Aug 9 '06 #1
3 8697
Dim is equivalent to Private. Change them to Public

/claes

"Bmack500" <br********@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
>I have a sub, and a class. The sub is like this:
Sub dothis()
Dim aInfoListX As New infoWrapperClass
aInfoListX.params = ReadConfig()
Dim sqlCMD As New SqlCommand
aInfoListX.sqlCmd = sqlCMD

aInfoListX.sqlConn = New
SqlClient.SqlConnection(aInfoListX.params.sqlserve r)
End Sub

Now, I have a class, with subclasses, as below. However, in the above
sub, it tells me that "aInfoLisX.params.sqlserver" is not accessible in
this context because it is private". I'm using VS 2005, vb.net. I don't
quite understand what's going on here..... Any help would be greatly
appreciated!
<deleted>
>
Public Class Configs
Dim logdirectory As String
Dim logfile As String
Dim errLog As String
Dim logfileops As Boolean
Dim logscreenops As Boolean
Dim userid As String
Dim password As String
Dim ldapServer As String
Dim prodSql As String
Dim testsql As String
Dim devsql As String
Dim tempFile As String
Dim log As String
Dim sqlServer As String
End Class
Public Class ServerInfo
Dim oDN As String
Dim oGUID As Guid
Dim oDOMAIN As String
Dim ostrGUID As String
Dim oNAME As String
Dim ipAddress As String
Dim oDNSHOSTNAME As String
Dim oDescription As String
Dim oOS As String
Dim oOSVersion As String
Dim oTZ As Int16
Dim oManagedBy As String
Dim oLastLogon As Date
Dim oSPMajor As Short
Dim oSPMinor As Short
Dim oCreateDate As Date
Dim oError As Boolean
Dim oElapsed As String
Dim isPartial As Boolean
Dim isUpdate As Boolean
Dim strHosts As String
Dim DNSREAD As Boolean
End Class
Public Class nicStruct
Dim CLASSGUID As String 'The Windows CLASSGUID identifier
Dim Subkey As String 'The subkey string to find the nic
values in
Dim Value As String 'The key who's value we need
Dim PNPid As String 'The PNPSHORT adapter identifier
Dim Service As String 'The driver
Dim Duplex As String 'The duplex setting found
Dim Speed As String 'The speed found (Unless set to auto)
Dim settings As String 'The result of the registry query on
the media (speed/duplex) requested
'Dim newreturn As String '?
Dim productName As String 'i.e. "HP NC7781 GIGABIT SERVER
ADAPTER"
Dim infPath As String 'What inf is the nic using?
Dim paramSubkey As String 'The subkey to fetch the
Speed/Duplex given from "settings"
Dim bError As Boolean
Dim strIndex As String
Dim netConnectionID As String 'As viewed in the Network
connections folder
End Class
End Class

Aug 9 '06 #2
Bmack500 wrote:
Sub dothis()
Dim aInfoListX As New infoWrapperClass
.. . .
aInfoListX.sqlConn = New
SqlClient.SqlConnection(aInfoListX.params.sqlserve r)
End Sub

it tells me that "aInfoLisX.params.sqlserver" is not accessible in
this context because it is private". I'm using VS 2005, vb.net.
Boiling down your code to the relevant bits ...
Public Class infoWrapperClass
.. . .
Public Property params() As configs
Get
Return CType(Item(7), configs)
End Get
.. . .
Public Class Configs
.. . .
Dim sqlServer As String
I suspect that "Dim" (within a Class) is equivalent to "Private" and not
to "Public", as you are assuming.

Except within a method, where you have no choice, abandon Dim to the
Past and use the "modern" Access Specifiers.

HTH,
Phill W.
Aug 9 '06 #3
Ahhh, sometimes being new at something with no formal training
sucks.... gotta go read some more!!!

Thank you very much.

Phill W. wrote:
Bmack500 wrote:
Sub dothis()
Dim aInfoListX As New infoWrapperClass
. . .
aInfoListX.sqlConn = New
SqlClient.SqlConnection(aInfoListX.params.sqlserve r)
End Sub

it tells me that "aInfoLisX.params.sqlserver" is not accessible in
this context because it is private". I'm using VS 2005, vb.net.

Boiling down your code to the relevant bits ...
Public Class infoWrapperClass
. . .
Public Property params() As configs
Get
Return CType(Item(7), configs)
End Get
. . .
Public Class Configs
. . .
Dim sqlServer As String

I suspect that "Dim" (within a Class) is equivalent to "Private" and not
to "Public", as you are assuming.

Except within a method, where you have no choice, abandon Dim to the
Past and use the "modern" Access Specifiers.

HTH,
Phill W.
Aug 9 '06 #4

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

Similar topics

6
by: F. Petitjean | last post by:
I want to know if iter(iterator) returns always its argument (when argument is an iterator) So : >>> iterable = range(10) >>> it = iter(iterable) >>> that = iter(it) >>> that is it True #...
7
by: Dan V. | last post by:
Still struggling with css. Anyone know how to put a tope background colour (matches the right part of the banner image) that stretches to the max. size of the window like the main div? My header...
0
by: Tom L | last post by:
I have a vb.net app that I created a setup for. I can install it and run it just fine on my XP box, but I'm having problems ont he NT4 workstation box. the nt4 box has sp6a, the .net 1.1 clr,...
22
by: john bailo | last post by:
oh man, i've been working all month on c# and now I get a java project. finally. life is great !!! -- http://www.museum.tv/ETV/G/htmlG/greenacres/greenacres.htm
7
by: Bill | last post by:
Hello, Here is some code: I'm thinking that when storing an object in an ArrayList or Hashtable that it clones the object. This can be shown like so: // key is a generated hashcode for this...
4
by: Jack Wright | last post by:
Dear All, I would like to read the processModel from machine.config. The following is code I have writte Dim hConfig As Object = ConfigurationSettings.GetConfig("system.web/processModel") But if...
1
by: Richard | last post by:
I keep getting this error and i dont know how 2 fix it. If someone knows how, please tell me :D Compilation Error Description: An error occurred during the compilation of a resource required to...
0
by: Bmack500 | last post by:
I'm getting an error when I try to access the properties in oResult, stating: "System.DirectoryServices.SearchResultCollection.Properties is not accessible in this context because it is 'private'"....
1
by: user | last post by:
Hello, With asp.net 2, i have a detailsview and a dropdownlist : I have create a databound event with the detailsview that take a value in the detailsview (with Data.DataRowView) to select a...
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: 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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.