|
-
Aug 31st, 2006, 11:46 AM
#1
Thread Starter
Lively Member
How would you do it?
I am wondering the best way to code this, I know it might not be a hard question, but this has been tickling me for a while:
I am wondering, which constitutes the best coding practice while having Option Strict On:
VB Code:
Btn_toggleUSR.Image = DirectCast(IIf(toggle_usr, Image.FromFile("...\unpressed_down.bmp"), Image.FromFile("...\unpressed_up.bmp")), Drawing.Image)
VB Code:
If toggle_usr Then Btn_toggleUSR.Image = Image.FromFile("...\unpressed_down.bmp") Else Btn_toggleUSR.Image = Image.FromFile("...\unpressed_up.bmp")
-
Aug 31st, 2006, 01:55 PM
#2
Frenzied Member
Re: How would you do it?
I my humble opinion, i would say do it like this:
VB Code:
If toggle_usr = True Then
Btn_toggleUSR.Image = Image.FromFile("...\unpressed_down.bmp")
Else
Btn_toggleUSR.Image = Image.FromFile("...\unpressed_up.bmp")
End If
~Peter

-
Aug 31st, 2006, 02:07 PM
#3
Re: How would you do it?
why not use an image list?... from the looks of things, this button will change its image somewhat often, and you will be constantly loading the image off the HD with your method.
-
Aug 31st, 2006, 02:22 PM
#4
-
Aug 31st, 2006, 02:29 PM
#5
Thread Starter
Lively Member
Re: How would you do it?
 Originally Posted by kleinma
why not use an image list?... from the looks of things, this button will change its image somewhat often, and you will be constantly loading the image off the HD with your method.
Thanks I see your point, will test immediately.
@MrGTI, thanks for the input
-
Aug 31st, 2006, 02:29 PM
#6
Re: How would you do it?
 Originally Posted by MrGTI
 Duh. I should have thought of that.
well in your defense.. out of his 2 original choices, I would have also picked the one you did
-
Aug 31st, 2006, 03:55 PM
#7
Thread Starter
Lively Member
Re: How would you do it?
Actually I thought of this afterwards, and it seems more logical for someone to read it like MrGTI proposes, although I did take out the '= true' part.
-
Sep 1st, 2006, 10:35 AM
#8
Frenzied Member
Re: How would you do it?
Kleinma is right.... if you're going to be changing the image often, and only between a few "standard" images, then an image list is better - since you won't have an error in your app if the image is deleted from the hard drive.
~Peter

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
|