?
Solved

Scroll down on Rolodex name list

Posted on 2003-03-21
7
Medium Priority
?
184 Views
Last Modified: 2010-04-07
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
Comment
Question by:GlobalFax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 5

Expert Comment

by:avya2k
ID: 8185311
the idea is not fully cleared
can you provide some details plz
0
 
LVL 1

Author Comment

by:GlobalFax
ID: 8185342
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
 
LVL 1

Author Comment

by:GlobalFax
ID: 8185345
i.e.   cmdScroll(0) and cmdScroll(2)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:avya2k
ID: 8185348
the idea is not fully cleared
can you provide some details plz
0
 
LVL 1

Author Comment

by:GlobalFax
ID: 8185349
Actually both cmd buttons perform a scrol up, when one should be up and one down.
0
 
LVL 5

Accepted Solution

by:
avya2k earned 2000 total points
ID: 8185391
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
 
LVL 1

Author Comment

by:GlobalFax
ID: 8185421
Bingo!!!!

Worked perfectly, thanks a million!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question