PDA

Click to See Complete Forum and Search --> : 2 Questions. Read my questions! Thank u.


Rose
Nov 29th, 1999, 12:11 AM
I have an image and a text on the form. I created a project that generates random pictures. Here is the below code in the form --
Private Sub Form_Load()

Randomize Timer
imgSign.Picture = LoadPicture(App.Path & "\sign" & Int(Rnd * 10) + 1 & ".jpg")

End Sub

But my question is how to select a random description(perhaps from a file), and it must match with the image.

i.e. the image randomly displays "cat, and the text randomly shows the definition of "cat" on the form .... it has to be matched with an image "cat"


I created the database in Access 97, and I got the code to define Word and Picture and Text

field name data type
word text
picture ole object
description memo

I added the data. And, the result are shown below

word picture description

cat picture an animal....
dog picture an animal....
car picture an automobile....
etc etc etc.......

But, I have the code, and I ran the program.. it says, "Unable to bind to field or DataMember. "Picture". I used the Data Form Wizard to create a form using the Employeers from the NWind.mdb database --- includes the pictures. When I ran that frmEmployeers, I got the same error!! I did not understand what does it mean by "Unable to bind....!" Can anyone tell me??? Thanks in advance.

ROSE
I am new to this BB. How do I respond back to someone's reply. Thank u.

MicahCarrick
Nov 29th, 1999, 01:17 AM
I know nothing about databases, but what I would do is create an INI file with the definitions corresponding with the image filenames. Fore example,


Dim iResult as string
iResult = space(255)
dim iDefault as string
iDefault = "Unable to read from INI file."

txtDefinition.text = getprivateprofilestring(imgWhatever.picture, "Definition" , iResult, len(iResult), "iDefault")

and then have the ini file look like this ...


[cat.bmp]
definition=meow meow meow

[dog.bmp]
definition=bark bark bark


Just an idea, I'm no expert. If you take that route, don't forget to declare:

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long


Good luck,
Micah Carrick

Blackthorne
Nov 29th, 1999, 01:37 AM
Personally I would stick with the database idea it is more flexible and neater looking from an end user perspective than an INI (in my opinion).

I'm assuming that you have managed to open and read from the database that you have created, right? If that is the case I would look into opening the database with a SQL statement that selects only the record associated with the picture. As for storing the images, I would keep them seperate like you were doing originally rather than trying to embed the information into the database.

------------------
Micheal Blackthorne

Rose
Nov 29th, 1999, 01:36 PM
I got my code working! Thanks so much for all of your help!