Results 1 to 7 of 7

Thread: How to control scrolling on textbox?

  1. #1

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    37

    Question

    Hi Folks,

    I have a textbox, and this has a lot of records in it. I also have a combobox, which is for the line of the records. How do I code my VB such that when user selects the nth line, my textbox will be able to display the nth line as the first line?

    For example, the contents of my textbox is as follows:

    "a", "for", "apple"
    "b", "for", "boy"
    "c", "for", "cat"
    "d", "for", "dog"
    "e", "for", "egg"
    "f", "for", "flower"
    "g", "for", "gun"

    If user selects 5 on my combobox, the textbox will automatically display this:

    "e", "for", "egg"
    "f", "for", "flower"
    "g", "for", "gun"

    but they would still be able to scroll up and down if they want.

    Thanks!
    Thanks for reading my post!

  2. #2
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224
    why do u need to use a textbox ?

    Using a List box is a lot easier in ur case.
    If you can't pronounce my name, call me GURU

  3. #3

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    37
    Hi G.Kumaraguru,

    Thanks for the response. I am using a textbox because that is what the teacher defined in the spec. I don't have any experience using a listbox. Would it be more easier to use that? Can you please give an example? Thanks so much!
    Thanks for reading my post!

  4. #4
    Guest
    Use Line Input. It might work.

  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Question

    What do you mean but they would still be able to scroll up and down if they want.?
    It is they still can scroll back to the first line? "a", "for", "apple"


  6. #6

    Thread Starter
    Member
    Join Date
    May 2000
    Posts
    37
    Hi Chris,

    That's right, the first line they should see on screen should be "e","for","egg", but when they scroll up, they should still be able to see previous records.... ie "a","for","apple", and so on....

    Thanks for reading my post!

  7. #7
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb SendMessage API

    Although it is recomended to do this by using the ListBox control like what G.Kumaraguru said. But you still can achieve this with the SendMessage API and two constant WM_KEYDOWN and VK_DOWN.

    Code:
    Option Explicit
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const WM_KEYDOWN = &H100
    Private Const VK_DOWN = &H28
    
    Private Sub Combo1_Click()
    Dim Cnt%
    Text1.SelStart = 1
    Cnt% = 0
    While Cnt <= CInt(Combo1)
        SendMessage Text1.hwnd, WM_KEYDOWN, VK_DOWN, 0&
        Cnt = Cnt + 1
    Wend
    Combo1.SetFocus
    End Sub

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