Results 1 to 7 of 7

Thread: runtime imagebox

  1. #1

    Thread Starter
    Hyperactive Member anita2002's Avatar
    Join Date
    Dec 2001
    Location
    In u'r Heart
    Posts
    482

    Exclamation runtime imagebox

    hello all,
    Can anybody explain me how to create imagebox at runtime
    and load an image in it?
    Please show it with an example if possible...
    Thanks in Advance,
    Anita.
    Can't imagine life without VB
    (Various Boyfriends)

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Without adding a control array first, you can do it this way.
    VB Code:
    1. Option Explicit
    2. Dim WithEvents imgNew As Image
    3.  
    4. Private Sub Command1_Click()
    5. Dim strPic As String
    6.  
    7. strPic = "C:\Program Files\Microsoft Visual Studio\" & _
    8.          "Common\Graphics\Icons\Misc\FACE02.ICO"
    9.          
    10. Set imgNew = Controls.Add("VB.Image", "imgNew")
    11. With imgNew
    12.     .Left = 100
    13.     .Top = 200
    14.     .Height = 800
    15.     .Width = 800
    16.     .Stretch = True
    17.     .Visible = True
    18.     .Picture = LoadPicture(strPic)
    19. End With
    20.  
    21. Command1.Visible = False
    22. End Sub
    23.  
    24. Private Sub imgNew_Click()
    25.     MsgBox "You clicked on your new control"
    26. End Sub

  3. #3
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    VB Code:
    1. Dim i As Image
    2.     Set i = Form1.Controls.Add("VB.Image", "img1")
    3.     i.Picture = LoadPicture("[i]filepath[/i]")
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  4. #4
    Hyperactive Member Dinz's Avatar
    Join Date
    Jan 2002
    Posts
    359
    the pic in avatar is urs????......... ..if so ur beautiful......

  5. #5
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    Originally posted by Dinz
    the pic in avatar is urs????......... ..if so ur beautiful......
    thanks! i look better without my santa hat on though
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  6. #6
    Hyperactive Member Dinz's Avatar
    Join Date
    Jan 2002
    Posts
    359
    Originally posted by darre1


    thanks! i look better without my santa hat on though
    darre1 u will be disheartened to know that I am talkin bout the first avatar i.e of anita2002..... .......

  7. #7
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    naaaaaaah realllyy???
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

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