Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Dallas, Texas
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Floating Fields (2002)

    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? <img src=/S/headthrob.gif border=0 alt=headthrob width=15 height=15>

  2. #2
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Floating Fields (2002)

    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.

  3. #3
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Dallas, Texas
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Floating Fields (2002)

    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. <img src=/S/compute.gif border=0 alt=compute width=40 height=20> <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Floating Fields (2002)

    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

  5. #5
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Floating Fields (2002)

    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! <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

  6. #6
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Dallas, Texas
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Floating Fields (2002)

    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.

  7. #7
    2 Star Lounger
    Join Date
    Jan 2003
    Location
    Dallas, Texas
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Floating Fields (2002)

    <P ID="edit" class=small>(Edited by charlotte on 17-Jun-04 12:57. Rule #10)</P>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. <img src=/S/devil.gif border=0 alt=devil width=15 height=15> 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

  8. #8
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using Regions: Was(Re: Floating Fields (2002))

    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! <img src=/S/sailing.gif border=0 alt=sailing width=25 height=25>
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •