• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

Scroll down on Rolodex name list

I need help on scrolling down, as I have the scrolling up working:


Option Explicit
Dim intCount As Integer, txtName() As String, x As Integer
Private Sub cmdAlphabet_Click(Index As Integer)
Dim intCount As Integer, intNameOccurance As Integer, txtName2 As String
    Select Case Index
        Case 0
        For intCount = 0 To x
        txtName2 = UCase(Left(txtName(x).Text, 1))
        If txtName2 = "A" Then
        intNameOccurance = intNameOccurance + 1
        End If
        Next intCount
        lblMessage.Caption = "There are " + intNameOccurance + "names begining with the letter A."
    End Select
End Sub

Private Sub cmdExit_Click()
    Unload frmRolodex
   
End Sub


Private Sub cmdScroll_Click(Index As Integer)
Dim intError As Integer
        If lstName.ListIndex = 0 Then
            intError = MsgBox("You have reached the first name in the file.", vbOKOnly, "Rolodex Error")
        Else
            lstName.ListIndex = Val(lstName.ListIndex - 1)
        End If
       
End Sub

Private Sub Form_Load()
    Top = (Screen.Height - frmRolodex.Height) / 2
    Left = (Screen.Width - frmRolodex.Width) / 2
        Open "D:\names.txt" For Input As (1)
        Do While Not EOF(1)
            ReDim Preserve txtName(x)
            Input #1, txtName(x)
            lstName.AddItem txtName(x)
            x = x + 1
        Loop
        Close 1
        lstName.ListIndex = 0
       
End Sub

0
GlobalFax
Asked:
GlobalFax
  • 4
  • 3
1 Solution
 
avya2kCommented:
the idea is not fully cleared
can you provide some details plz
0
 
GlobalFaxAuthor Commented:
I have this Names.txt file that I load, I display the list of names on the lstlNames textbox, I have two cmd button using cmdScroll (one as up and one as down).   The scroll up works but the scroll down down does not work.
0
 
GlobalFaxAuthor Commented:
i.e.   cmdScroll(0) and cmdScroll(2)
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
avya2kCommented:
the idea is not fully cleared
can you provide some details plz
0
 
GlobalFaxAuthor Commented:
Actually both cmd buttons perform a scrol up, when one should be up and one down.
0
 
avya2kCommented:
my browser get refreshed to post same comments
any way try this if works


Option Explicit

Private Sub Command1_Click(index as integer)
    if(index=0)then  'Scroll down
       If (List1.ListIndex = -1) Then
           List1.ListIndex = 0
       ElseIf (List1.ListIndex + 1 < List1.ListCount) Then
           List1.ListIndex = List1.ListIndex + 1
       Else
           MsgBox "reached to end of list"
       End If
    else 'Scroll up
       If (List1.ListIndex > 0) Then
           List1.ListIndex = List1.ListIndex - 1
       Else
           MsgBox "reached to start of list"
       End If
    end if
End Sub

0
 
GlobalFaxAuthor Commented:
Bingo!!!!

Worked perfectly, thanks a million!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now