Based the image attached possible to create a paging of a dictonary array?
Note:
The label is named LTEST, when appaer the actually value of paging item
PAGING dictionary array
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
PAGING dictionary array
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: PAGING dictionary array
In image have 4 button.
> Goto the next item of array, >> goto the last item of array , < bak one item of array,<< first item of array....ecc
During the sroll, show in label the current item value.
> Goto the next item of array, >> goto the last item of array , < bak one item of array,<< first item of array....ecc
During the sroll, show in label the current item value.
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: PAGING dictionary array
That's not really detailed information...
Let's say you have an array MyArray.
Let's say you have an array MyArray.
Code: Select all
Dim MyIndex As Long
Private Sub cmdBack_Click()
If MyIndex > LBound(MyArray) Then
MyIndex = MyIndex - 1
LTEST.Caption = MyArray(MyIndex)
End If
End Sub
Private Sub cmdFirst_Click()
MyIndex =LBound(MyArray)
LTEST.Caption = MyArray(MyIndex)
End Sub
Private Sub cmdLast_Click()
MyIndex = UBound(MyArray)
LTEST.Caption = MyArray(MyIndex)
End Sub
Private Sub cmdNext_Click()
If MyIndex < UBound(MyArray) Then
MyIndex = MyIndex + 1
LTEST.Caption = MyArray(MyIndex)
End If
End Sub
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 563
- Joined: 27 Jun 2021, 10:46
Re: PAGING dictionary array
Why not use a scrollbar control?
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: PAGING dictionary array
hi. bro.HansV wrote: ↑16 Mar 2023, 21:13That's not really detailed information...
Let's say you have an array MyArray.
Code: Select all
Dim MyIndex As Long Private Sub cmdBack_Click() If MyIndex > LBound(MyArray) Then MyIndex = MyIndex - 1 LTEST.Caption = MyArray(MyIndex) End If End Sub Private Sub cmdFirst_Click() MyIndex =LBound(MyArray) LTEST.Caption = MyArray(MyIndex) End Sub Private Sub cmdLast_Click() MyIndex = UBound(MyArray) LTEST.Caption = MyArray(MyIndex) End Sub Private Sub cmdNext_Click() If MyIndex < UBound(MyArray) Then MyIndex = MyIndex + 1 LTEST.Caption = MyArray(MyIndex) End If End Sub
confused...
i have a dictionary item, not a tiical array, sorry.
thi is my code:
Code: Select all
Private Sub MSFlexGrid1_Click()
If CLng(Me.LNRAR.Caption) >= 1 Then
With MSFlexGrid1
.Redraw = False
R = .MouseRow
C = .Col
.Row = R
.Col = C
If R >= 1 Then
Select Case C
Case 0
If .CellPicture = Me.Image1.Picture Then
Set .CellPicture = Me.Image2.Picture
VALORE = .TextMatrix(R, C + 1)
MYDICT.Add R, VALORE
.TextMatrix(R, 10) = 2
Me.LNR.Caption = CLng(Me.LNR.Caption) + 1
Else
Set .CellPicture = Me.Image1.Picture
VALORE = .TextMatrix(R, C + 1)
MYDICT.Remove R
.TextMatrix(R, 10) = 1
Me.LNR.Caption = CLng(Me.LNR.Caption) - 1
End If
Case 1
If .TextMatrix(R, 9) > "" Then
IMG = .TextMatrix(R, 9)
Call APRI_IMG
Else
IMG = "NONDISP.jpg"
Call APRI_IMG
End If
End Select
.Redraw = True
End If
End With
End If
End Sub
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: PAGING dictionary array
After you have filled MYDICT, you can get an array of all items:
MYARRAY = MYDICT.Items
MYARRAY = MYDICT.Items
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4364
- Joined: 26 Apr 2010, 17:36
Re: PAGING dictionary array
WOW!!! tks
quicly remove item in array list based VALORE, without a for next?
is this part:
...
VALORE = .TextMatrix(R, C + 1)
MYDICT.Remove R
'...
'here the code to remove item VALORE from Myarray just filled
...
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
-
- 4StarLounger
- Posts: 563
- Joined: 27 Jun 2021, 10:46
Re: PAGING dictionary array
Here's how you might use a scrollbar
Code: Select all
'Assumes a form with a Label called Label1 and an hScroll called HCroll1
Option Explicit
Private MyDic As Dictionary
Private Sub Form_Load()
InitialiseExample
End Sub
Private Sub InitialiseExample()
Set MyDic = PopulateDictionary ' get an example dictionary
SetupScrollbar HScroll1, MyDic ' Set up scrollbar appropriate for this dictionary
End Sub
' This is for example. Obviously you will already have a dictionary, so you would not need to do this bit
Private Function PopulateDictionary() As Dictionary
Set PopulateDictionary = New Dictionary
Dim lp As Long
For lp = 1 To 100
' In this example dictionary is holding strings, but could be anything, e.g. Picture objects
PopulateDictionary.Add "Label " & lp, "Dictionary Item " & lp
Next
End Function
' Sets up an HScroll to scroll appropriately for a specific dictionary object
Private Sub SetupScrollbar(targetscroll As HScrollBar, targetdic As Dictionary)
With targetscroll
.Max = targetdic.Count - 1
.Min = 0 ' lowest element of a Dictionary
.SmallChange = 1
.LargeChange = .Max - .Min
.Value = .Max
.Value = .Min ' cheap way to force a change event
End With
End Sub
' Show appropriate dictionary item when we scroll
Private Sub HScroll1_Change()
Label1.Caption = MyDic.Items(HScroll1.Value)
End Sub