|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Class item not accessible because it's private... but it's not?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.sqlserver) 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 Dim is equivalent to Private. Change them to Public
/claes Show quoteHide quote "Bmack500" <brett.m***@gmail.com> wrote in message <deleted>news:1155128911.891872.191540@m79g2000cwm.googlegroups.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.sqlserver) > 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! Show quoteHide quote > > 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 > Bmack500 wrote:
> Sub dothis() Boiling down your code to the relevant bits ...> Dim aInfoListX As New infoWrapperClass .. . . > aInfoListX.sqlConn = New > SqlClient.SqlConnection(aInfoListX.params.sqlserver) > 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. > Public Class infoWrapperClass I suspect that "Dim" (within a Class) is equivalent to "Private" and not .. . . > Public Property params() As configs > Get > Return CType(Item(7), configs) > End Get .. . . > Public Class Configs .. . . > Dim sqlServer As String 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. Ahhh, sometimes being new at something with no formal training
sucks.... gotta go read some more!!! Thank you very much. Phill W. wrote: Show quoteHide quote > Bmack500 wrote: > > > Sub dothis() > > Dim aInfoListX As New infoWrapperClass > . . . > > aInfoListX.sqlConn = New > > SqlClient.SqlConnection(aInfoListX.params.sqlserver) > > 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.
Referencing Controls created at run time.
FileListBox from VB6? Help with first VB application - Data Entry form Easy Value Compare Question MS VB Newbie Tutorial Check to see if a server is running Check if a Windows service running Dataset Writing to a file opened in another class Multi-level TreeNode storing? |
|||||||||||||||||||||||