Image Arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lotus18
    Contributor
    • Nov 2007
    • 865

    Image Arrays

    Hello World

    I'm back again. LOL


    How to make an image arrays? I have 6 images named Button (Index from 1-6). I'm working on MouseMove events these images. So far I have these codes:

    [CODE=vb]Public Sub DefaultImage()
    It should be array
    For i = 1 To 6
    Button(i).Pictu re = LoadPicture(App .Path & "\Images\Button Normal.jpg")
    Next i
    End Sub

    Private Sub Button_MouseMov e(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    ...
    End Sub

    [/CODE]


    This is my previous code and the Button were not on control arrays. This is working. I just want to shorten my codes. Thanks : )

    [CODE=vb]Public Sub DefaultImage()
    Button1.Picture = LoadPicture(App .Path & "\Images\Button Normal.jpg")
    Button2.Picture = LoadPicture(App .Path & "\Images\Button Normal.jpg")
    Button3.Picture = LoadPicture(App .Path & "\Images\Button Normal.jpg")
    Button4.Picture = LoadPicture(App .Path & "\Images\Button Normal.jpg")
    Button5.Picture = LoadPicture(App .Path & "\Images\Button Normal.jpg")
    Button6.Picture = LoadPicture(App .Path & "\Images\Button Normal.jpg")
    End Sub

    Private Sub Button1_MouseMo ve(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DefaultImage
    Button1.Picture = LoadPicture(App .Path & "\Images\Button Hot.jpg")
    End Sub

    ...

    Private Sub Button6_MouseMo ve(Button As Integer, Shift As Integer, X As Single, Y As Single)
    DefaultImage
    Button6.Picture = LoadPicture(App .Path & "\Images\Button Hot.jpg")
    End Sub
    [/CODE]
    Last edited by lotus18; Jan 14 '08, 05:21 AM. Reason: vb code tag added
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    What is the problem with the new code ?

    Comment

    • QVeen72
      Recognized Expert Top Contributor
      • Oct 2006
      • 1445

      #3
      Hi,

      Just change your Mouse move event like this..


      [CODE=vb]
      Public Sub DefaultImage()
      Dim i As Integer
      For i = 1 To 6
      Button(i).Pictu re = LoadPicture(App .Path & "\Images\Button Normal.jpg")
      Next i
      End Sub

      Private Sub Button_MouseMov e(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
      DefaultImage
      Button(Index).P icture = LoadPicture(App .Path & "\Images\Button Hot.jpg")
      End Sub

      [/CODE]


      Regards
      Veena

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        Originally posted by debasisdas
        What is the problem with the new code ?
        Hi

        Thanks for replying. If you notice that on my first code line #9 it contains only .... Hehe...

        Comment

        • lotus18
          Contributor
          • Nov 2007
          • 865

          #5
          Hi Veena

          Thanks. I'll try that later : )

          Comment

          • lotus18
            Contributor
            • Nov 2007
            • 865

            #6
            Originally posted by QVeen72
            Hi,

            Just change your Mouse move event like this..


            [CODE=vb]
            Public Sub DefaultImage()
            Dim i As Integer
            For i = 1 To 6
            Button(i).Pictu re = LoadPicture(App .Path & "\Images\Button Normal.jpg")
            Next i
            End Sub

            Private Sub Button_MouseMov e(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
            DefaultImage
            Button(Index).P icture = LoadPicture(App .Path & "\Images\Button Hot.jpg")
            End Sub

            [/CODE]


            Regards
            Veena
            Hi Veena

            I tried it and there's an error. The error says that an Compile Error: Expected Array :(

            Comment

            • QVeen72
              Recognized Expert Top Contributor
              • Oct 2006
              • 1445

              #7
              Hi,

              Which Line you are getting the error...?
              What version ? VB6 or VB.net...?


              Regards
              Veena

              Comment

              • lotus18
                Contributor
                • Nov 2007
                • 865

                #8
                Originally posted by QVeen72
                Hi,

                Which Line you are getting the error...?
                What version ? VB6 or VB.net...?


                Regards
                Veena
                Hi

                Sorry for the late reply. I'm getting an error at line #10. I'm using vb6.

                Comment

                • Killer42
                  Recognized Expert Expert
                  • Oct 2006
                  • 8429

                  #9
                  In VB6, you're much better off using control arrays. But I don't quite understand what the problem is, or why you are moving away from control arrays.

                  Comment

                  • Killer42
                    Recognized Expert Expert
                    • Oct 2006
                    • 8429

                    #10
                    Sorry, I'm confused. which is the old code, and which is the new?

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      I think this may be the line you're after...
                      [CODE=vb]Button(Index).P icture = LoadPicture(App .Path & "\Images\Button Hot.jpg")[/CODE]

                      Comment

                      • pureenhanoi
                        New Member
                        • Mar 2007
                        • 175

                        #12
                        Originally posted by lotus18
                        Hi Veena

                        I tried it and there's an error. The error says that an Compile Error: Expected Array :(
                        This error occures caused of Pictures in your form in diffrent name (Button1, button2...)
                        If you want use the given code, set the same name for 6 picturebox. Just named them with "Button". If VB6 ask you to create an array of picturebox, click "Yes" to accept.
                        If you could see in the Property window, all of these picturebox have same name "Button", and the Index property is increment from 0..5. So that the good time for runing given code again.

                        I must edit some thing on my post, caused the given code use "For i=1 To 6"
                        You can use "For i=0 To 5" instead, or set the index of 6 pictureboxs increment from 1..6
                        Last edited by pureenhanoi; Jan 15 '08, 11:03 AM. Reason: add info

                        Comment

                        • lotus18
                          Contributor
                          • Nov 2007
                          • 865

                          #13
                          Originally posted by pureenhanoi
                          This error occures caused of Pictures in your form in diffrent name (Button1, button2...)
                          If you want use the given code, set the same name for 6 picturebox. Just named them with "Button". If VB6 ask you to create an array of picturebox, click "Yes" to accept.
                          If you could see in the Property window, all of these picturebox have same name "Button", and the Index property is increment from 0..5. So that the good time for runing given code again.

                          I must edit some thing on my post, caused the given code use "For i=1 To 6"
                          You can use "For i=0 To 5" instead, or set the index of 6 pictureboxs increment from 1..6
                          Hi

                          If notice on my 1st post, in code #1, I stated there that the name of my Image is Button and they are in array control (Index from 1 to 6). But in code #2 on the same post, my buttons which are the images are not in control array instead, they are named as Button1, Buttton2,...Button6

                          Rey Sean

                          Comment

                          • klvnwafu
                            New Member
                            • Jan 2008
                            • 2

                            #14
                            hello world,
                            what is the code for arc sine and arc cosine please help thank you!

                            Comment

                            • lotus18
                              Contributor
                              • Nov 2007
                              • 865

                              #15
                              Originally posted by klvnwafu
                              hello world,
                              what is the code for arc sine and arc cosine please help thank you!
                              Hello

                              You are out of the topic. Please start a new thread.

                              Rey Sean

                              Comment

                              Working...