|
-
Jun 11th, 2000, 03:14 AM
#1
Thread Starter
Member
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!
-
Jun 11th, 2000, 03:49 AM
#2
Addicted Member
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 
-
Jun 11th, 2000, 03:56 AM
#3
Thread Starter
Member
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!
-
Jun 11th, 2000, 04:37 AM
#4
Use Line Input. It might work.
-
Jun 11th, 2000, 07:47 AM
#5
PowerPoster
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"
-
Jun 12th, 2000, 06:03 AM
#6
Thread Starter
Member
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!
-
Jun 12th, 2000, 07:20 AM
#7
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|