|
-
Feb 9th, 2003, 10:56 PM
#1
Thread Starter
Lively Member
Random Access Files without UDT's
I am using Random File Access and I want each record to be defined like this
Key as Integer
Name as string * 50
DOB as date
SSN as string * 11
Is there a way I can define each record without using a User Defined Type? Is there a way I could use a collection instead or some other method? As far as I know the only way to do this is by using a UDT.
-
Feb 9th, 2003, 11:39 PM
#2
Hyperactive Member
I don't know much about random file access but...
you could create a class module and add that to a collection.
Keep in mind that Dictionaries are much faster than collections and with a dictionary you check if a Key exists or not.
-
Feb 13th, 2003, 10:39 AM
#3
Thread Starter
Lively Member
Dictionaries
What is a "Dictionaries"? Also how would I add the fields to a collection?
-
Feb 13th, 2003, 11:13 AM
#4
Frenzied Member
U could Use PropertyBags as well. Just wondering, why not UDTs?
"Brothers, you asked for it."
...Francisco Domingo Carlos Andres Sebastian D'Anconia
-
Feb 13th, 2003, 10:58 PM
#5
Hyperactive Member
-
Feb 14th, 2003, 03:58 PM
#6
Thread Starter
Lively Member
I would love to use UDT's but I really don't know how I can pass a UDT from a DLL to a exe program. My exe program is calling the dll. So is there a way I can get the structure of the UDT? Example of my UDT is:
Private type tmyType
Name as string * 50
date as double
Number as string * 20
iNumberLines as integer
end Type
public myType as tmyType
Now how would the exe know what field are in the UDT that is defined in the DLL?
-
Feb 14th, 2003, 04:34 PM
#7
A UDT must be declared as Public in a Class module. UDT Strings cannot be fixed length.
VB Code:
[b][i]DLL Class1[/i][/b]
Public Type tmyType
Name As String
date As Double
Number As String
iNumberLines As Integer
End Type
Public Property Get SampleData() As tmyType
Dim udtTemp As tmyType
udtTemp.Name = "Hello World"
udtTemp.date = Now
udtTemp.Number = "1000"
udtTemp.iNumberLines = 734
SampleData = udtTemp
End Property
[b][i]Client exe project[/i][/b]
Dim objTest As Project1.Class1
Dim udtTest As Project1.tmyType
Set objTest = New Project1.Class1
udtTest = objTest.SampleData
Debug.Print udtTest.Name, udtTest.Date, udtTest.iNumberLines, udtTest.Number
Set objTest = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|