• Floating Fields (2002)

    Author
    Topic
    #406172

    I’m sorry to bother you busy folks with what is just a matter of curiosity, but IT”S KILLING ME! My instructor offered extra credit for writing code that would cause the textboxes (with their labels) to “float” across the form from right to left for 10 iterations. I get the LOOP thing. That wasn’t any problem. I couldn’t find anything to give me a clue about making a textbox “float”. The assignment is turned in. I should be able to forget it, right? Well I can’t. Could someone ease my pain? headthrob

    Viewing 3 reply threads
    Author
    Replies
    • #840213

      I would assume that the instructor wanted you to change the left positions of the textbox and label. That would cause the controls to Move. That’s my guess.

      • #841054

        Hello Drew, fellow Dallasite
        I haven’t seen your name for a while. Okay – change the left positions. And you would do that by —— ? Remember who your dealing with here. This is my first actual VBA course that I’m taking. compute wink

        • #841060

          Each control has Left and Top properties that determine its position, and Width and Height properties that determine its size. In Visual Basic, they are measured in twips, where 1 inch = 1440 twips. So to position a text box txtSomething one inch from the left side of the form, use

          Me.txtSomething.Left = 1440

          Or to move it 1/2 inch to the right from its current position:

          Me.txtSomething.Left = Me.txtSomething.Left + 720

        • #841061

          Each control has Left and Top properties that determine its position, and Width and Height properties that determine its size. In Visual Basic, they are measured in twips, where 1 inch = 1440 twips. So to position a text box txtSomething one inch from the left side of the form, use

          Me.txtSomething.Left = 1440

          Or to move it 1/2 inch to the right from its current position:

          Me.txtSomething.Left = Me.txtSomething.Left + 720

          • #841774

            Twips. Twips! Yes, that was in the book. I didn’t make the connection. I’m not sure I could have figured it out if I did. Thanks for your help with a matter of no importance whatever, except to me.

          • #841775

            Twips. Twips! Yes, that was in the book. I didn’t make the connection. I’m not sure I could have figured it out if I did. Thanks for your help with a matter of no importance whatever, except to me.

        • #841146

          Actually, I am truly a Dallasite now. I used to live in Mckinney, but I moved into Dallas back in April. LONG story.

          As to your post, let me try to explain in a more ‘intuitive’ way. VB/VBA is supposed to be an object oriented programming language. This is a touchy subject, because C programmers will harp on the fact that VB does not have inheritence. (VB.Net does, but VB 6.0, and VBA (which is a subset of VB, sort of…VB is also a subset of VBA) doesn’t). Anyhow, there are two types of code within VB/VBA. Objects and Processes. An object has attributes, a process has an outcome. Take for example a form. A form has attributes, such as height, width, background color, etc. A process just has an outcome, like UCase. UCase turns a string into all Caps.

          Now, it gets a bit more complicated then that, but processes and objects are the basics. Processes can deal with objects, and objects can have processes. In this particular case, you want to use an objects properties, to create a process, the Left property, to cause the control to ‘float’. Now, we could just do something like this:

          Sub Float()
          Dim i As Long
          For i = 1 To 10
          Do Until Me.txtFloat.Left + Me.txtFloat.Width = Me.Width
          Me.txtFloat.Left = Me.txtFloat.Left + 1
          Screen.ActiveForm.Repaint
          Loop
          Do Until Me.txtFloat.Left = 0
          Me.txtFloat.Left = Me.txtFloat.Left – 1
          Screen.ActiveForm.Repaint
          Loop
          Next i
          End Sub

          This ‘floats’ a control called txtFloat, from right to left, ten times. This is a process, that changes an object’s attributes. However, it is only doing one control. If you really want to build something to affect all textboxes, let me know, just don’t want to make a 5 page post! wink

          • #841772

            (Edited by charlotte on 17-Jun-04 12:57. Rule #10)

            Ah ha! The light comes on. Looking back, I can now see where it is in the book. It doesn’t give you this, it just talks about pixels and – twixes?? I suppose all the information was there if I were brighter. Now — even though the credit is no longer on the table, I would still like to incorporate this in my final project, which my instructor has deemed ” a little strange, but well thought out.” All he asks for is that all the data in the tables be exported and the database shut down after 2 or 3 erroneous login attempts. I’m getting there.
            I really would like to have the textboxes “float away” before the database closes. Just to show him I kept trying. I’m also going to attempt to have it turn bright red and beep. devil Just because I am a little strange.

            I would also like to hear the long story about how you wound up in Dallas.

            Thanks Drew

          • #841773

            (Edited by charlotte on 17-Jun-04 12:57. Rule #10)

            Ah ha! The light comes on. Looking back, I can now see where it is in the book. It doesn’t give you this, it just talks about pixels and – twixes?? I suppose all the information was there if I were brighter. Now — even though the credit is no longer on the table, I would still like to incorporate this in my final project, which my instructor has deemed ” a little strange, but well thought out.” All he asks for is that all the data in the tables be exported and the database shut down after 2 or 3 erroneous login attempts. I’m getting there.
            I really would like to have the textboxes “float away” before the database closes. Just to show him I kept trying. I’m also going to attempt to have it turn bright red and beep. devil Just because I am a little strange.

            I would also like to hear the long story about how you wound up in Dallas.

            Thanks Drew

        • #841147

          Actually, I am truly a Dallasite now. I used to live in Mckinney, but I moved into Dallas back in April. LONG story.

          As to your post, let me try to explain in a more ‘intuitive’ way. VB/VBA is supposed to be an object oriented programming language. This is a touchy subject, because C programmers will harp on the fact that VB does not have inheritence. (VB.Net does, but VB 6.0, and VBA (which is a subset of VB, sort of…VB is also a subset of VBA) doesn’t). Anyhow, there are two types of code within VB/VBA. Objects and Processes. An object has attributes, a process has an outcome. Take for example a form. A form has attributes, such as height, width, background color, etc. A process just has an outcome, like UCase. UCase turns a string into all Caps.

          Now, it gets a bit more complicated then that, but processes and objects are the basics. Processes can deal with objects, and objects can have processes. In this particular case, you want to use an objects properties, to create a process, the Left property, to cause the control to ‘float’. Now, we could just do something like this:

          Sub Float()
          Dim i As Long
          For i = 1 To 10
          Do Until Me.txtFloat.Left + Me.txtFloat.Width = Me.Width
          Me.txtFloat.Left = Me.txtFloat.Left + 1
          Screen.ActiveForm.Repaint
          Loop
          Do Until Me.txtFloat.Left = 0
          Me.txtFloat.Left = Me.txtFloat.Left – 1
          Screen.ActiveForm.Repaint
          Loop
          Next i
          End Sub

          This ‘floats’ a control called txtFloat, from right to left, ten times. This is a process, that changes an object’s attributes. However, it is only doing one control. If you really want to build something to affect all textboxes, let me know, just don’t want to make a 5 page post! wink

      • #841055

        Hello Drew, fellow Dallasite
        I haven’t seen your name for a while. Okay – change the left positions. And you would do that by —— ? Remember who your dealing with here. This is my first actual VBA course that I’m taking. compute wink

    • #840214

      I would assume that the instructor wanted you to change the left positions of the textbox and label. That would cause the controls to Move. That’s my guess.

    • #843675

      Just so we don’t leave everyone in the dark, I am posting a ‘flashy’ method of closing a form, and even closing Access. This is what LadyGnome is going to use instead of ‘floating’ the controls. There are three forms. The ‘twist out’ form doesn’t really twist, I would have to use transformations to do that, and just don’t have time to mess around with that right now.

      The modules in this db are completely standalone, so you can import them into any project you want. Use the code behind the buttons on the sample forms to see how it works. (The functions only require the forms hWnd value).

      Enjoy! sailing

    • #843676

      Just so we don’t leave everyone in the dark, I am posting a ‘flashy’ method of closing a form, and even closing Access. This is what LadyGnome is going to use instead of ‘floating’ the controls. There are three forms. The ‘twist out’ form doesn’t really twist, I would have to use transformations to do that, and just don’t have time to mess around with that right now.

      The modules in this db are completely standalone, so you can import them into any project you want. Use the code behind the buttons on the sample forms to see how it works. (The functions only require the forms hWnd value).

      Enjoy! sailing

    Viewing 3 reply threads
    Reply To: Floating Fields (2002)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: