naravno da bi mogli ali ako nisi dosad radio sa bazama ja bih ti preporucio nesto jednostavnije:
ubaci ovaj kod u modul:
Code:
Option Explicit
Public Sub WriteData(sFile As String, Entry As String, Value As Variant)
Dim propBag As New PropertyBag
Dim varData As Variant
Dim b() As Byte
Dim ff As Integer
If Dir(sFile) <> vbNullString Then
ff = FreeFile
Open sFile For Binary As #ff
Get #ff, , varData
Close #ff
b = varData
propBag.Contents = b
On Error Resume Next
Call Kill(sFile)
End If
Call propBag.WriteProperty(Entry, Value)
ff = FreeFile
Open sFile For Binary As #ff
Put #ff, , propBag.Contents
Close #ff
End Sub
Public Function readData(sFile As String, Entry As String, Optional def As Variant)
Dim propBag As New PropertyBag
Dim varData As Variant
Dim b() As Byte
Dim ff As Integer
If Dir(sFile) <> vbNullString Then
ff = FreeFile
Open sFile For Binary As #ff
Get #ff, , varData
Close #ff
b = varData
propBag.Contents = b
readData = propBag.ReadProperty(Entry, def)
End If
End Function
Public Function readObject(sFile As String, Entry As String) As Object
Dim propBag As New PropertyBag
Dim varData As Variant
Dim b() As Byte
Dim ff As Integer
If Dir(sFile) <> vbNullString Then
ff = FreeFile
Open sFile For Binary As #ff
Get #ff, , varData
Close #ff
b = varData
propBag.Contents = b
Set readObject = propBag.ReadProperty(Entry)
End If
End Function
i imas svoju bazu! :)
a funkcije koristis ovako:
Code:
'ovako upisujes sliku (ili text, broj, objekat...) u bazu:
Call WriteData("C:\test.data", "SomePicture", Picture1.Picture)
'ovako citas sliku (objekat) iz baze:
Picture1.Picture = readObject("C:\test.data", "somepicture")
'a text (broj, ili bilo sta sem objekta) citas ovako:
Text1.Text = ReadData("C:\test.data", "Test_Value042")
samo moras da vodis racuna da ti u Entry stringu nema ramaka i da pocinje sa slovom i da sme samo da sadrzi a-z,A-Z,0-9,_ (kao property neke kontrole...)
ovo nije los nacin da se odradi to sto ti treba, mada bi trebalo jednom da naucis da radis sa "pravim" bazama jer ce ti to kad tad zatrebati...
pozdrav