Results 1 to 4 of 4

Thread: How to display an image in a Userform on setting the path

  1. #1
    Join Date
    Jun 2009
    Posts
    59

    How to display an image in a Userform on setting the path

    In a userform I want to display an image (jpg). On the other hand, I have some pictures in a directory. Until no problems. For instant I display as follows:

    If my test = "mountain"
    I display the image (mountain)
    Image1.Picture = LoadPicture ( "c:\images\mountain.jpg)

    That is my concern:

    Now according to a result (variable) tests, I would like to view the image. As I have quite a picture and then test to write. Is it possible to pass the filename as a parameter? Like:

    Image1.Picture = LoadPicture("c:\images\MyImage.jpg")

    MyImage is the parameter to load depending on the test result

  2. #2
    Join Date
    Nov 2008
    Posts
    1,054

    Re: How to display an image in a Userform on setting the path

    Hello, anything goes as

    Code:
    Image1.Picture = LoadPicture("c:\images\" & MyImage &".jpg")

  3. #3
    Join Date
    Jun 2009
    Posts
    59

    Re: How to display an image in a Userform on setting the path

    Thank you, it worked! I tried something in the genre but it lacked the separators " & xxxxxx & ". What is their role? Another question. How to adjust the size of a Userform to the size of the screen? Knowing that I like to use my applications on any PC.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,054

    Re: How to display an image in a Userform on setting the path

    "&" is the concatenation operator.

    For the later refer vb-helper codes:

    A form that covers the entire screen including the taskbar area:

    Code:
    Private Sub Form_Load()
    Dim wid As Long
    Dim hgt As Long
    
        ' Get the screen's size including the task bar area.
        wid = GetSystemMetrics(SM_CXSCREEN)
        hgt = GetSystemMetrics(SM_CYSCREEN)
    
        ' Make the form of this size.
        Move 0, 0, _
            ScaleX(wid, v***xels, vbTwips), _
            ScaleY(hgt, v***xels, vbTwips)
    End Sub
    Fill the screen with your form :

    set:

    ControlBox = False
    Caption = ""
    WindowState = Maximized
    BorderStyle = None
    Code:
    Private Sub Form_Resize()
        picCenter.BorderStyle = vbBSNone
        picCenter.Move _
            (ScaleWidth - picCenter.Width) / 2, _
            (ScaleHeight - picCenter.Height) / 2
    End Sub
    How to get the screen's current resolution

    Code:
    Private Sub Form_Load()
    Dim wid As Integer
    Dim hgt As Integer
    
        wid = Screen.Width \ Screen.TwipsPerPixelX
        hgt = Screen.Height \ Screen.TwipsPerPixelY
    
        Label1.Caption = Format$(wid) & " x " & Format$(hgt)
    End Sub

Similar Threads

  1. Replies: 7
    Last Post: 15-02-2012, 05:29 AM
  2. Display setting for the Motorola Motoactv
    By BaasimaP in forum Portable Devices
    Replies: 4
    Last Post: 14-11-2011, 04:55 PM
  3. Setting DMA and Display Settings in Windows
    By FlashX in forum Tips & Tweaks
    Replies: 2
    Last Post: 25-03-2009, 01:26 PM
  4. Installing Java JDK and setting PATH
    By Paramartha in forum Software Development
    Replies: 4
    Last Post: 25-02-2009, 05:17 PM
  5. Display Setting Changes in Mozilla.
    By Ramchandra in forum Technology & Internet
    Replies: 4
    Last Post: 16-01-2009, 11:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,172,936.82969 seconds with 17 queries