|
-
Nov 11th, 2002, 11:48 AM
#1
Thread Starter
Lively Member
IF statement problems
VB Code:
If strTemp2 = varAnimals Then
Image1.Picture = LoadPicture(App.Path & strTemp3)
Else
Image1.Picture = LoadPicture(App.Path & "\pics\not.jpg")
End If
what I want the code to do is if strTemp2 = varAnimals then it displays the correct picture (strTemp3 is the pictures path that gets read from a txt file)
or if there is no picture listed in the file to display not.jpg. It displays the not pic but does not display the ones that have pics...
Patience with me Please! I'm Learning!
Self Learning Newbie
VB 6 Pro SP4
-
Nov 11th, 2002, 11:55 AM
#2
Frenzied Member
Maybe there is white space in either of the variables so the if statemnet never is true??
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Nov 11th, 2002, 11:56 AM
#3
Make sure that both data types are strings.... varAnimals sounds like a variant, producing unreliable results.
-
Nov 11th, 2002, 11:57 AM
#4
Frenzied Member
Originally posted by techgnome
Make sure that both data types are strings.... varAnimals sounds like a variant, producing unreliable results.
Yes... use CStr(varAnimals) to make sure.
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Nov 11th, 2002, 12:01 PM
#5
Addicted Member
i think its the line
VB Code:
Image1.Picture = LoadPicture(App.Path & strTemp3)
it should be
VB Code:
Image1.Picture = LoadPicture(App.Path & "\" & strTemp3)
-
Nov 11th, 2002, 12:18 PM
#6
Thread Starter
Lively Member
changed code to this
VB Code:
If strTemp2 = CStr(varAnimals) Then
Image1.Picture = LoadPicture(App.Path & strTemp3)
Else
Image1.Picture = LoadPicture(App.Path & "\pics\not.jpg")
End If
the file it reads from is formated like
AARDWOLF =\pics\aardwolf.jpg
strTemp2 returns as AARDWOLF so does varAnimals (both look the same when I check them.)
strTemp 3 returns as \pics\aardwolf.jpg
Then not pic loads fine the listed pics do not
[EDIT]
After futher testing it is not going past the If Then line when I select an animal with a picture
Last edited by spiritwolf; Nov 11th, 2002 at 12:22 PM.
Patience with me Please! I'm Learning!
Self Learning Newbie
VB 6 Pro SP4
-
Nov 11th, 2002, 12:49 PM
#7
Thread Starter
Lively Member
Ok so for some reason that wasn't working so what I did was set Image1.Picture to "\pics\not.jpg" then used
VB Code:
Select Case varAnimals
Case strTemp2
Image1.Picture = LoadPicture(App.Path & strTemp3)
End Select
And this works
Patience with me Please! I'm Learning!
Self Learning Newbie
VB 6 Pro SP4
-
Nov 11th, 2002, 12:54 PM
#8
hrrmmm...... the only thing I can think of is:
"A" <> "a" ... so "AARDVARK" <> "Aardvark"
But..... the SELECT CASE isn't case sensitive....... ????
-
Nov 11th, 2002, 01:04 PM
#9
Thread Starter
Lively Member
Yes it is but everything was already set up for upper case.
Patience with me Please! I'm Learning!
Self Learning Newbie
VB 6 Pro SP4
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
|