ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto move scroll bars of listbox (https://www.excelbanter.com/excel-programming/322215-auto-move-scroll-bars-listbox.html)

JON JON

Auto move scroll bars of listbox
 
Dear Ng,

I had created a user form which is not modal that serves as splash screen
while my macro runs into the background. This userform includes a listbox
that is populated during runtime. My problem now is that when the entries
in the listbox exceed beyond it size, the latest entries are being hide in
view. Is there a way that I can move the scroll bars of the listbox so that
I can show the latest entries in view.

All help will be highly appreciated.

Regards,

Jon-jon





Tom Ogilvy

Auto move scroll bars of listbox
 
Look at the topIndex property of the Listbox.

--
Regards,
Tom Ogilvy

"JON JON" wrote in message
...
Dear Ng,

I had created a user form which is not modal that serves as splash screen
while my macro runs into the background. This userform includes a

listbox
that is populated during runtime. My problem now is that when the

entries
in the listbox exceed beyond it size, the latest entries are being hide

in
view. Is there a way that I can move the scroll bars of the listbox so

that
I can show the latest entries in view.

All help will be highly appreciated.

Regards,

Jon-jon







keepITcool

Auto move scroll bars of listbox
 
topindex demo...

Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Private Sub UserForm_activate()
Dim i%
With ListBox1
For i = 1 To 100
.AddItem "item" & Format(i, " 000")
If .ListCount 5 Then
.TopIndex = .ListCount - 5
End If
Me.Repaint
Sleep 100
Next
End With
Unload Me
End Sub

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote :

Look at the topIndex property of the Listbox.


JON JON

Auto move scroll bars of listbox
 
Keep ITcool,

Thank you very much it was a great help.

Can you please extend more help by explaining what does the "Sleep 100" do?
I am just really curious about it.

TIA,

Jon-jon



"keepITcool" wrote in message
ft.com...
topindex demo...

Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Private Sub UserForm_activate()
Dim i%
With ListBox1
For i = 1 To 100
.AddItem "item" & Format(i, " 000")
If .ListCount 5 Then
.TopIndex = .ListCount - 5
End If
Me.Repaint
Sleep 100
Next
End With
Unload Me
End Sub

--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote :

Look at the topIndex property of the Listbox.




keepITcool

Auto move scroll bars of listbox
 
Jon, jon

similar as application.wait the Sleep function suspends the execution
of the current thread for a specified interval. This is a so called
windows API call.

the sleep is just for the demo to keep the loop slow enough to see it
move...



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


JON JON wrote :

Keep ITcool,

Thank you very much it was a great help.

Can you please extend more help by explaining what does the "Sleep
100" do? I am just really curious about it.

TIA,

Jon-jon



"keepITcool" wrote in message
ft.com...
topindex demo...

Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Private Sub UserForm_activate()
Dim i%
With ListBox1
For i = 1 To 100
.AddItem "item" & Format(i, " 000")
If .ListCount 5 Then
.TopIndex = .ListCount - 5
End If
Me.Repaint
Sleep 100
Next
End With
Unload Me
End Sub

--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam



Tom Ogilvy wrote :

Look at the topIndex property of the Listbox.


JON JON

Auto move scroll bars of listbox
 
Again, thank you very much


"keepITcool" wrote in message
ft.com...
Jon, jon

similar as application.wait the Sleep function suspends the execution
of the current thread for a specified interval. This is a so called
windows API call.

the sleep is just for the demo to keep the loop slow enough to see it
move...



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


JON JON wrote :

Keep ITcool,

Thank you very much it was a great help.

Can you please extend more help by explaining what does the "Sleep
100" do? I am just really curious about it.

TIA,

Jon-jon



"keepITcool" wrote in message
ft.com...
topindex demo...

Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Private Sub UserForm_activate()
Dim i%
With ListBox1
For i = 1 To 100
.AddItem "item" & Format(i, " 000")
If .ListCount 5 Then
.TopIndex = .ListCount - 5
End If
Me.Repaint
Sleep 100
Next
End With
Unload Me
End Sub

--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam


Tom Ogilvy wrote :

Look at the topIndex property of the Listbox.





All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com