CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Arrays of Picture Objects

    I have set up an array of Picture Objects using the code

    private Sub Form_Load()
    public gifObjects (1 to 4) as Picture

    set gifObjects (1) = LoadPicture ("c:Apps\one.gif")
    set gifObjects (2) = LoadPicture ("c:Apps\two.gif")
    set gifObjects (3) = LoadPicture ("c:Apps\three.gif")
    set gifObjects (4) = LoadPicture ("c:Apps.four.gif")
    End Sub




    I have a TextBox on one Form which can hold numbers form 1 to 4. I would like to have some code to state that if the TextBox.Text = 1 Then load gifObjects(1) into the PictureBox I have called picGIFs. If TextBox.Text = 2 Then load gifObjects(2) etc.

    The TextBox is on one form and the PictureBox is on a second form. Will this be an additional problem?

    Has anyone got any suggestions?

    MTS



  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Arrays of Picture Objects

    Picgif must have Autoredraw = true. Ths following code goes into Form1

    Option Explicit
    Dim gifObjects(1 To 4) As Picture

    Private Sub Command1_Click()
    Load Form2
    Form2.picGif.Picture = gifObjects(Text1.Text)
    Form2.Show
    End Sub


    Private Sub Form_Load()
    Set gifObjects(1) = LoadPicture("c:\windows\Cloud.gif")
    Set gifObjects(2) = LoadPicture("c:\windows\Content.gif")
    Set gifObjects(3) = LoadPicture("c:\windows\hlpCd.gif")
    Set gifObjects(4) = LoadPicture("c:\windows\Hlpglobe.gif")

    Text1 = 1
    End Sub


    John G

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

Featured