Results 1 to 16 of 16

Thread: Very easy question...

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    40
    I'm really a beginner so I need an answer for this stupid question:
    How to make a text box and do that everything you'll write in it will immediately appear on the form.

  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Say the name of the text box is " txtMyBox " then all u do is:
    Private sub txtMyBox_Change()
    [ whatever you want to say it in] = txtMyBox.text
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    40

    maybe i'm wrong but...

    i ment that the text box itself would be empty but when you run the app, when you'll write something it will also apear on the form.

  4. #4
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I don't get it, is this what u mean :
    1. you want it to copy the text you put in the textbox on to another object ?

    2. You want it to put text into the text box when the form is loaded or on another event?

    3. Other.
    Last edited by Electroman; Jun 6th, 2004 at 04:56 AM.

  5. #5
    Fanatic Member
    Join Date
    Aug 2000
    Location
    I'm right here!
    Posts
    849
    If you want that what you put in a text box will be on the
    form you should use this code:

    Private Sub Text1_Change()
    Me.Cls
    Print Text1.Text
    End Sub


    Try it.

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    40
    No,
    What i mean is, to do a simple program that only has a text box control, when you write something in the text box it will also apear on the form.
    let's say i want to do the same thing only the text will apear as the form's caption, i will do something like this:

    text1.text = form1.caption

    i want to do the same thing only the text will apear on the form...

  7. #7
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    You mean, appear on the form's title.
    Exactly the opposite of the other code:
    Code:
    Form1.Caption = Text1.Text

  8. #8

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    40
    Thanks everyone but the example of Dekelc already work.
    no can someone explain it please, what do this mean:

    Private Sub Text1_Change()
    Me.Cls
    Print Text1.Text
    End Sub


  9. #9
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Here, it's commented.
    Code:
    Private Sub Text1_Change() ' Code below will execute when you type something in the TextBox
    Cls ' Remove whatever it says on the form
    Print Text1.Text ' Print on the form whatever it says on the TextBox
    End Sub

  10. #10

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    40
    Thanks For everyone that Helped,
    but i have another small question (i'm sorry):
    If I take out the "cls", it jumps to a new line every
    time I write another letter.
    why?

  11. #11
    Addicted Member Xenonic_Rob's Avatar
    Join Date
    Jun 2000
    Location
    England, UK
    Posts
    213
    It will do - the Print command goes to a new line and writes whatever.

    You are new at VB aren't you.....?!

    Rob Wright
    E-mail: [email protected]
    Website: http://www.xenonic.com
    The First Member of Honeybee's Club
    Favourite words: Zugzwang and Empiric

  12. #12

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    40
    I already said i'm new to VB (my first week),
    but you didn't answer my question:
    cls just supose to clear the form,isn't it,
    so why if I delete it, every time i write a letter
    it jumps to a new line and write it.

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Cls clears the form and also resets the drawing origin (where it starts from) to the top left. Every time you call Print, it moves this origin down to below the last printed text.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Private Sub Text1_Change()
    Me.Cls
    Print Text1.Text
    End Sub

    doesn't jump for me...
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  15. #15

    Thread Starter
    Member
    Join Date
    Sep 2000
    Posts
    40
    OK, i'm done, thanks!

  16. #16
    Guest
    Originally posted by macron
    Thanks For everyone that Helped,
    but i have another small question (i'm sorry):
    If I take out the "cls", it jumps to a new line every
    time I write another letter.
    why?
    If you do not like where it prints, you can set it by changing the CurrentX and CurrentY properties.

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