Private Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type
Printable View
Private Type HOSTENT
hName As Long
hAliases As Long
hAddrType As Integer
hLen As Integer
hAddrList As Long
End Type
A 'Private Type' has been set up called HOSTENT.
HOSTENT contains 5 elements, in this case Longs and Integers.
You can access those elements by Dimensioning a variable as the HOSTENT, Like:
VB Code:
Dim PersDetails as HOSTENT PersDetails.hName = 1234 PersDetails.hAliases = 45657 'etc 'And, then display them like: Msgbox PersDetails.hName Msgbox PersDetails.hAliases
Note: The Data Types dont seem to reflect the wanted use tho.
ie. Shouldn't hName be dimensioned as a String?
Bruce.
Heres an (Excell VB) Extract:
Quote:
Type Statement
Used at module level to define a user-defined data type containing one or more elements.
Syntax
[Private | Public] Type varname
elementname [([subscripts])] As type
[elementname [([subscripts])] As type]
. . .
End Type
The Type statement syntax has these parts:
Part Description
Public Optional. Used to declare user-defined types that are available to all procedures in all modules in all projects.
Private Optional. Used to declare user-defined types that are available only within the module where the declaration is made.
varname Required. Name of the user-defined type; follows standard variable naming conventions.
elementname Required. Name of an element of the user-defined type. Element names also follow standard variable naming conventions, except that keywords can be used.
subscripts When not explicitly stated in lower, the lower bound of an array is controlled by the Option Base statement. The lower bound is zero if no Option Base statement is present.
type Required. Data type of the element; may be Byte, Boolean, Integer, Long, Currency, Single, Double, Decimal (not currently supported), Date, String (for variable-length strings), String * length (for fixed-length strings), Object, Variant, another user-defined type, or an object type.
Remarks
The Type statement can be used only at module level. Once you have declared a user-defined type using the Type statement, you can declare a variable of that type anywhere within the scope of the declaration. Use Dim, Private, Public, ReDim, or Static to declare a variable of a user-defined type.
In standard modules and class modules, user-defined types are public by default. This visibility can be changed using the Private keyword.
Line numbers and line labels aren't allowed in Type...End Type blocks.
User-defined types are often used with data records, which frequently consist of a number of related elements of different data types.
The following example shows the use of fixed-size arrays in a user-defined type:
Type StateData
CityCode (1 To 100) As Integer ' Declare a static array.
County As String * 30
End Type
Dim Washington(1 To 100) As StateData
In the preceding example, StateData includes the CityCode static array, and the record Washington has the same structure as StateData.
When you declare a fixed-size array within a user-defined type, its dimensions must be declared with numeric literals or constants rather than variables.
Thanks brucefox...
actually its my fault... i did not specify correctly...... what i mean is the structure type is used in a section to call for IPHOSTNAME... and they often use this structure to get the information ... so i would like to know what are the content in those Struct
Quote:
Originally posted by vbnew
... so i would like to know what are the content in those Struct
One simple way would be to use the MsgBox method above to confirm the data.
Ya lah,
damn , i am so stupid .............. Thanks Bruce Fox. maybe i am a little bit lazy to key in that line of code.... lazyness hell..... BruceFox thanks.... (maybe i am too eager untill all hell in my brain) Thanks
Well, I had previously done it, so here it is :)
VB Code:
Option Explicit Private Type HOSTENT hName As Long hAliases As Long hAddrType As Integer hLen As Integer hAddrList As Long End Type Private Sub SomeSub() Dim IPHostDetails As HOSTENT IPHostDetails.hName = 'something from your Connection to the URL IPHostDetails.hAliases = 'something from your Connection to the URL 'etc 'etc 'And, then display them like: MsgBox IPHostDetails.hName MsgBox IPHostDetails.hAliases MsgBox IPHostDetails.hAddrType MsgBox IPHostDetails.hLen MsgBox IPHostDetails.hAddrList End Sub
Better yet:
VB Code:
MsgBox "IPName: " & IPHostDetails.hName & vbCrLf _ & "IPAliases: " & IPHostDetails.hAliases & vbCrLf _ & "IPAddrType: " & IPHostDetails.hAddrType & vbCrLf _ & "IPLen: " & IPHostDetails.hLen & vbCrLf _ & "IPAddrList: " & IPHostDetails.hAddrList