Results 1 to 7 of 7

Thread: VB.net users Unite!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    4

    VB.net users Unite!!

    Hello I'm new and would like to introduce myself to everybody. The only reason I signed up is because of my lack of VB.net knowledge.

    I got a couple of questions for people who wants to help.

    Here's the set-up:
    I changed the form background with an image
    I want to be able to change the background image from another image by a click of a button. Is this possible? If so then what's the code for this. I'm quessing I have to change the assembly or something but what do I know.

    I am using VB.net so
    I know nothing that's why I need your help

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    Double click on the button, in the click even put

    Code:
    form1.ActiveForm.BackgroundImage.FromFile(FileNameOfImage)

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    are you after changing the image with another which is embedded? or an image from a location on the HD ?
    if it's from an embedded resource....
    VB Code:
    1. [Color=Blue]Dim[/COLOR] path [Color=Blue]As[/COLOR] [Color=Blue]String[/COLOR] = Application.ProductName & ".DCP_0567.JPG"
    2.         [Color=Blue]MyBase[/COLOR].BackgroundImage = Image.FromStream([Color=Blue]MyBase[/COLOR].GetType.Assembly.GetManifestResourceStream(path))
    if it's from a file ...
    VB Code:
    1. [color=blue]MyBase[/color].BackgroundImage = Image.FromFile(" path of image here ")
    Last edited by dynamic_sysop; Oct 29th, 2003 at 04:30 PM.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  4. #4
    Lively Member formulav8's Avatar
    Join Date
    Mar 2002
    Location
    Orlando
    Posts
    116
    Another way is:


    VB Code:
    1. Dim bit As Bitmap = New Bitmap("c:\yourPicture.jpg")
    2.  
    3.         Me.BackgroundImage = bit

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2003
    Posts
    4
    Umm. Like I said I'm a real newb at this

    On the three codes that were given to me. Umm where should I input them. DO I put them in the button or the somewhere else.
    I know nothing that's why I need your help

  6. #6
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Don't use
    VB Code:
    1. Image.FromFile

    It doesn't close the file, so if you call upon it again, you will have problems (File resource being used elsewhere or file already open).

    Its not a bug per se, it was supposed to be 'by design'.

    Anyway, just use FromStream instead. That way you can explicitly close the image file when you are done loading it, and reuse it.
    Last edited by nemaroller; Oct 30th, 2003 at 05:44 PM.

  7. #7
    New Member dervish's Avatar
    Join Date
    Nov 2003
    Posts
    1
    yes, neo, code them to the button's click event (assuming you want the image to change when the user clicks the button).

    great sig, btw, sysop.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width