CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2001
    Location
    Tennessee
    Posts
    33

    Textbox Questions

    (1) I need to know how to change how the scrollbars are (ex. vertical to horizontal) when you click a button.
    _____

    (2) I have a menu with "Del" as a hot key for Delete, but now the actual delete code doesn't work.
    _____

    (3) I need code for a select all action.
    _____

    (4) I've got code for putting the date and time but I need it to insert the date and time where the blinking cursor is.

    NeOmega

  2. #2
    Join Date
    May 2001
    Location
    MO, USA
    Posts
    87

    Re: Textbox Questions

    select all....this will select all the text in a text box when it has the focus

    private sub text1_gotfocus()
    sendkey"+{end}"
    end sub

    date time at the cursor....this code will place the date and time in a text box..it can be done at form load time or when the textbox or label has focus...

    private sub form_load()
    text1.text = now
    end sub

    private sub text1_gotfocus()
    text1.text = now
    end sub

    hope this helps

    midnightservice


  3. #3
    Join Date
    Nov 2001
    Location
    India
    Posts
    20

    Re: Textbox Questions

    SendKeys "+{END}" holds good when the Multiline property of the TextBox is false.

    If the Multiline property of the TextBox is set to true, then

    Private Sub Text1_GotFocus()
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    End Sub





  4. #4
    Join Date
    Jul 2001
    Location
    Trivandrum, Kerala, India
    Posts
    21

    Re: Textbox Questions

    Dear NeOmega,

    The ScrollBar property of text boxes is read only at runtime. So changin the scroll bar property is impossible. But you can place four text boxes with different scroll bar properties in a form and show one by one. By doing this user feels that the scroll bar propery is changing.

    The following code illustrates this. To run this code place a CommandButton and four text boxes of a control array - text1(0), text1(1), text1(2) and text1(3). Then set MultiLine property of all text boxes to True. Again set ScrollBar property of Text1(0) to 0, Text1(1) to 1, so on. Set Visible property of all text boxes except text1(0) to false. The paste the following code and run the program.


    private Sub Command1_Click()
    static i as Integer
    Dim j as Integer

    ' hide all text boxes
    for j = 0 to 3
    Text1(j).Visible = false
    next j

    ' move one text box to position of text1(0)
    Text1(i).Move Text1(0).Left, Text1(0).Top, _
    Text1(0).Width, Text1(0).Height
    ' make that text box visible
    Text1(i).Visible = true

    ' increment i so that next time
    ' next text box will be shown
    i = (i + 1) Mod 4
    End Sub




    To place date and time in the cursor position of a text box, do following.

    Text1.SelText=now

    All the best.

    Kishore.


  5. #5
    Join Date
    Oct 2001
    Location
    Tennessee
    Posts
    33

    Re: Textbox Questions

    That worked. Now I need to know how have the same text on each textbox, so if I type on one then I switch to another, the text I just typed is there.

    NeOmega

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