Solved

Multiple Function Controls

Posted on 2003-12-04
5
174 Views
Last Modified: 2010-05-03
I have two buttons, "Previous" and "Next".  I have multiple textbox arrays.  What I want to do is, when you click on the "Next" button the next textbox array will show, press the "Next" button again and the nex textbox after that will show, etc.

The "Previous" button needs to do the same only in reverse.  As little coding as possible would be nice.

Thanks!
0
Comment
Question by:johnqtr
  • 2
  • 2
5 Comments
 
LVL 24

Expert Comment

by:shivsa
ID: 9880159
Hi trixits,
no it not possible, the same question asked before on this many times, but answer was always no.

Cheers!
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9880168
sorry for my last comment, it was for some other post.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 9880857
It's probably more complicated than I think, but does approach the problem?

Private Sub cmdNext_Click()
    Dim i As Integer
    Dim bFlag As Boolean
    Dim bFlag2 As Boolean
    Const iBoxCount = 3
    'ensures that there is no more than one box visible
    Do Until i = iBoxCount
        If bFlag2 Then
            Text1(i).Visible = False
        Else
            If bFlag Then
               Text1(i).Visible = True
               bFlag2 = True
            Else
                If Text1(i).Visible Then
                    Text1(i).Visible = False
                    bFlag = True
                End If
            End If
        End If
        i = i + 1
    Loop
   
    'Restart at beginning
    If bFlag = False Or bFlag2 = False Then
        Text1(0).Visible = True
    End If

End Sub
0
 
LVL 2

Accepted Solution

by:
lttia1 earned 125 total points
ID: 9881082
Try this:

For this, you have to ensure that only 1 textbox is visible at runtime

Private Sub cmdNext_Click()
  Dim HighestIndex As Long
  Dim LowestIndex As Long
  Dim Index As Long
 
  HighestIndex = Text1.UBound
  LowestIndex = Text1.lBound
 
  For Index = LowestIndex To HighestIndex - 1
    If Text1(Index).Visible = True Then
      Text1(Index).Visible = False
      Text1(Index + 1).Visible = True
      Exit For
    End If
  Next
End Sub

Private Sub cmdPrevious_Click()
  Dim HighestIndex As Long
  Dim LowestIndex As Long
  Dim Index As Long
 
  HighestIndex = Text1.UBound
  LowestIndex = Text1.lBound
 
  For Index = HighestIndex To LowestIndex + 1 Step -1
    If Text1(Index).Visible = True Then
      Text1(Index).Visible = False
      Text1(Index - 1).Visible = True
      Exit For
    End If
  Next
End Sub
0
 
LVL 2

Expert Comment

by:lttia1
ID: 9881114
this means that except for textbox(0)(example), you have to set the rest of the textbox array visible property to false at design time
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now