Click to See Complete Forum and Search --> : i need ideas in...
ariel_au
April 7th, 2001, 09:43 PM
well, i had loaded array of images during run-time and when the user clicks on the imagebox then the image is shown and when the user clicks on the other imagebox then the other image also shown.
well my problem is that, how can i compare the image which is first clicked with the image which is second clicked?
if both pics are of the same then both pics will remain in the imagebox (means shown), else both pics is closed (means unload picture).
private Sub imagebox_Click(Index as Integer)
:
:
:
ariel_au
April 8th, 2001, 01:19 AM
i am doing it in this way, but does not worked out well, can someone help me?
i am comparing the filename instead see below:
if both filename are same then i load the 2 similar pics
else if the two filename are not the same then i unload the 2 pics.
private Sub imgbox_Click(Index as Integer)
Dim filepath as string
Dim tem1 as string, tem2 as string
Dim num1 as Integer, num2 as Integer
static j%
filepath = "C:\Unzipped Files\pics\Icons" & "\im" & imgControl(Index).Tag & ".ico"
imgControl(Index).Picture = LoadPicture(filepath)
j% = j% + 1
If j = 1 then 'first click on one pic..
tem1$ = filepath 'store filename to here...
num1 = Index 'store index to a number
End If
If j = 2 then 'second click on the other pic....
tem2$ = filepath 'store filename here...
num2 = Index
End If
If tem1$ = tem2$ then 'when 2 filenames are same
imgControl(num1).Picture = LoadPicture(tem1) 'load pics when they are of the same
imgControl(num2).Picture = LoadPicture(tem2)
else 'when not the same then clear the two pics
imgControl(num1).Picture = LoadPicture()
imgControl(num2).Picture = LoadPicture()
End If
If j% > 3 then 'reset counter
j% = 0
End If
does anyone know how to solve this?
coolbiz
April 8th, 2001, 12:01 PM
Try this one:
' NOTE: assumption here is that your image control
' index starts from 1 instead of 0
private Sub imgControl_Click(Index as Integer)
static nLastIndex as Integer ' stores the last clicked imgControl
' load picture and save PATH into the .TAG of control
dim szPicPath as string
szPicPath = "C:\Unzipped Files\pics\Icons" & "\im" & imgControl(Index).Tag & ".ico"
set imgControl(Index).Picture = LoadPicture(szPicPath)
imgControl(Index).Tag = szPicPath ' save it
' check if last index > 0
if (nLastIndex > 0) then
' this is a second click - check if it is the same imgControl
if (nLastIndex = Index) then ' nothng to do so exit
exit sub
end if
'
' compare path
if (ucase(imgControl(nLastIndex).Tag) <> ucase(imgControl(Index).Tag)) then
' clear image on both image control
set imgControl(nLastIndex).Picture = nothing
set imgControl(Index).Picture = nothing
end if
'
' reset the last index
nLastIndex = 0
else
' save this index
nLastIndex = Index
end if
End Sub
Have not really tested that code, email me if you still having problems with it:
-Cool Bizs
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.