Link to home
Start Free TrialLog in
Avatar of ote
ote

asked on

TextBox

In VB4 I have a form, a FileListBox (which includes some jpg pictures), an Image and a TextBox.
With a click in the name of any picture in the FileListBox, the picture appears in the Image.
(I use the command:
f$ = File1.Path + "\" + File1.filename
image1.Picture = LoadPicture(f$)
How could I, for any picture I load, a certain text to be displayed in the TextBox? (Which will describe the picture).  
I would not like to use the «ListIndex», because the order and the number of the pictures will be change from time to time.  
What I want is when the picture (city.jpg for example), is loaded, a certain text for this picture to be displayed.
ASKER CERTIFIED SOLUTION
Avatar of Vbmaster
Vbmaster

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mcrider
mcrider

If you want to be able to change your text without recompiling your program, you can put your text in an ASCII file or a database.  Key the file with the name of the JPG file...

Then all you have to do is read the file or database...

For example, in a file, you could have the following lines:

   CITY.JPG:A city.. or something
   STATE.JPG:A state.. or something

Then you could read the file and split the record read into fields and test the fields, like in this function:

function GetText(Filename as string) as string
dim fnum as long
dim buf as string
dim ival as integer
dim arg1 as string
dim arg2 as string
fnum=freefile
open "myfile" for input access read as #fnum
do while not eof(fnum)
   line input #fnum, buf
   ival=instr(1,buf,":")
   arg1=left$(buf,ival-1)
   arg2=mid$(buf,ival+1)
   if Filename=arg1 then
      GetText=arg2
      exit do
   end if
loop
close fnum
end function


Cheers!
Got a sample project on my web page that pulls up images and text from an Access database. Visit www.cyberchute.com/rvbus/madmark

M
Avatar of ote

ASKER

I accept the simple answer of VBmaster.
That was what I needed!
I'll keep the valuable answer of mcrider for some next effort of mine.
Thanks!
Glad I could help...


Cheers!