ShowAgain2

Make selected item in listbox to be displayed at center of listbox after refreshing instead of bottom or top of list.
Helpful when yo have listbox with many items making selecting items very hard
Lst2 is hard-coded inside code

CodeFunctionName
What is this?

Public

Tested

Original Work
Sub ShowAgain2(SelectedItemListIndex, Items_Per_Page)
' Lst2 is listbox name
Items_Per_Page = 16 ' Number of listitems visible at scroll
Go1 = SelectedItemListIndex - Int(Items_Per_Page / 2)
Go2 = SelectedItemListIndex + Int(Items_Per_Page / 2)
If Go1 < 0 Then Go1 = 0
If Go2 > Lst2.ListCount - 1 Then Go2 = Lst2.ListCount - 1
Lst2.ListIndex = Go1 ' Go to 1st item
Lst2.ListIndex = Go2 ' Then go to last item
Lst2.ListIndex = SelectedItemListIndex ' Then re-activate selected item
End Sub

SelectedItemListIndex, Items_Per_Page

Views 3,229

Downloads 1,416

CodeID
DB ID

ANmarAmdeen
602
Revisions

v1.0

Sunday
June
24
2018