Hi,
I'm new to VB6 and I'm trying (just to get the hang of things) to create a phonebook using flatfiles. (I'll need the flatfile-parsing for future stuff)
I created a class that looks like this:
--
'local variable(s) to hold property value(s)
Private mvarFirstName As Variant 'local copy
Private mvarLastName As Variant 'local copy
Private mvarTelNumber As Variant 'local copy
Private mvarEmailAddress As Variant 'local copy
Public Function StringOut(Optional lstrSeparator As Variant = " :: ") As String
strOutString = mvarFirstName & lstrSeparator & mvarLastName & lstrSeparator & mvarTelNumber & lstrSeparator & mvarEmailAddress
End Function
Public Property Let EmailAddress(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.EmailAddress = 5
mvarEmailAddress = vData
End Property
Public Property Set EmailAddress(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.EmailAddress = Form1
Set mvarEmailAddress = vData
End Property
Public Property Get EmailAddress() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.EmailAddress
If IsObject(mvarEmailAddress) Then
Set EmailAddress = mvarEmailAddress
Else
EmailAddress = mvarEmailAddress
End If
End Property
Public Property Let TelNumber(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.TelNumber = 5
mvarTelNumber = vData
End Property
Public Property Set TelNumber(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.TelNumber = Form1
Set mvarTelNumber = vData
End Property
Public Property Get TelNumber() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.TelNumber
If IsObject(mvarTelNumber) Then
Set TelNumber = mvarTelNumber
Else
TelNumber = mvarTelNumber
End If
End Property
Public Property Let LastName(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.LastName = 5
mvarLastName = vData
End Property
Public Property Set LastName(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.LastName = Form1
Set mvarLastName = vData
End Property
Public Property Get LastName() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.LastName
If IsObject(mvarLastName) Then
Set LastName = mvarLastName
Else
LastName = mvarLastName
End If
End Property
Public Property Let FirstName(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.FirstName = 5
mvarFirstName = vData
End Property
Public Property Set FirstName(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.FirstName = Form1
Set mvarFirstName = vData
End Property
Public Property Get FirstName() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.FirstName
If IsObject(mvarFirstName) Then
Set FirstName = mvarFirstName
Else
FirstName = mvarFirstName
End If
End Property
--
and now I would like to create an array in my application that can hold data-types of that class, to store the records I read from my flat files...
Unfortunatly, I cannot find any way to define an array using this class as type (it gives me run-time errors).
--o0o--
Just to be as complete as possible, this is my last effort for now...
--
Open lblTelBoek.Caption For Input As 1
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, strTelBkLine ' Read data into two variables.
intPosOfSemiColon = InStr(strTelBkLine, ";") 'a trailing $ forces the variable to 'string'.
strFullName = Left(strTelBkLine, intPosOfSemiColon - 1)
intPosOfNameSeparator = InStr(strFullName, " ")
Set persoon1.intRecordTeller = New Contact
With persoon1.intRecordTeller
FirstName = Left(strFullName, intPosOfNameSeparator - 1)
LastName = Right(strFullName, Len(strFullName) - inPosOfNameSeparator)
TelNumber = Right(strTelBkLine, Len(strTelBkLine) - intPosOfSemiColon)
End With
intRecordTeller = intRecordTeller + 1
Loop
Close
--
(Beware: this code probably suxx bigtime, but I got tired after #-times without finding any decent tutorial online :/ If you can point me to a great online tutorial that might help this PL-SQL/perl/php-developer become a half-decent VB-coder, I'ld be very grateful)
I'm new to VB6 and I'm trying (just to get the hang of things) to create a phonebook using flatfiles. (I'll need the flatfile-parsing for future stuff)
I created a class that looks like this:
--
'local variable(s) to hold property value(s)
Private mvarFirstName As Variant 'local copy
Private mvarLastName As Variant 'local copy
Private mvarTelNumber As Variant 'local copy
Private mvarEmailAddress As Variant 'local copy
Public Function StringOut(Optional lstrSeparator As Variant = " :: ") As String
strOutString = mvarFirstName & lstrSeparator & mvarLastName & lstrSeparator & mvarTelNumber & lstrSeparator & mvarEmailAddress
End Function
Public Property Let EmailAddress(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.EmailAddress = 5
mvarEmailAddress = vData
End Property
Public Property Set EmailAddress(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.EmailAddress = Form1
Set mvarEmailAddress = vData
End Property
Public Property Get EmailAddress() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.EmailAddress
If IsObject(mvarEmailAddress) Then
Set EmailAddress = mvarEmailAddress
Else
EmailAddress = mvarEmailAddress
End If
End Property
Public Property Let TelNumber(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.TelNumber = 5
mvarTelNumber = vData
End Property
Public Property Set TelNumber(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.TelNumber = Form1
Set mvarTelNumber = vData
End Property
Public Property Get TelNumber() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.TelNumber
If IsObject(mvarTelNumber) Then
Set TelNumber = mvarTelNumber
Else
TelNumber = mvarTelNumber
End If
End Property
Public Property Let LastName(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.LastName = 5
mvarLastName = vData
End Property
Public Property Set LastName(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.LastName = Form1
Set mvarLastName = vData
End Property
Public Property Get LastName() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.LastName
If IsObject(mvarLastName) Then
Set LastName = mvarLastName
Else
LastName = mvarLastName
End If
End Property
Public Property Let FirstName(ByVal vData As Variant)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.FirstName = 5
mvarFirstName = vData
End Property
Public Property Set FirstName(ByVal vData As Variant)
'used when assigning an Object to the property, on the left side of a Set statement.
'Syntax: Set x.FirstName = Form1
Set mvarFirstName = vData
End Property
Public Property Get FirstName() As Variant
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.FirstName
If IsObject(mvarFirstName) Then
Set FirstName = mvarFirstName
Else
FirstName = mvarFirstName
End If
End Property
--
and now I would like to create an array in my application that can hold data-types of that class, to store the records I read from my flat files...
Unfortunatly, I cannot find any way to define an array using this class as type (it gives me run-time errors).
--o0o--
Just to be as complete as possible, this is my last effort for now...
--
Open lblTelBoek.Caption For Input As 1
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, strTelBkLine ' Read data into two variables.
intPosOfSemiColon = InStr(strTelBkLine, ";") 'a trailing $ forces the variable to 'string'.
strFullName = Left(strTelBkLine, intPosOfSemiColon - 1)
intPosOfNameSeparator = InStr(strFullName, " ")
Set persoon1.intRecordTeller = New Contact
With persoon1.intRecordTeller
FirstName = Left(strFullName, intPosOfNameSeparator - 1)
LastName = Right(strFullName, Len(strFullName) - inPosOfNameSeparator)
TelNumber = Right(strTelBkLine, Len(strTelBkLine) - intPosOfSemiColon)
End With
intRecordTeller = intRecordTeller + 1
Loop
Close
--
(Beware: this code probably suxx bigtime, but I got tired after #-times without finding any decent tutorial online :/ If you can point me to a great online tutorial that might help this PL-SQL/perl/php-developer become a half-decent VB-coder, I'ld be very grateful)