Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Incremental Counting

Posted on 1999-07-06
2
Medium Priority
?
206 Views
Last Modified: 2011-09-20
Hi, I've got a form with a 70 check boxes on it and 70 corresponding text boxes on it.  They are both control arrays.  I have coded them so that when a check box is clicked the corresponding text box next to it becomes visible.  Now what I want to do is have a number appear in the text box starting with 1 and increment up by 1 each time another check box on the form is clicked.  Thus, if a user clicked on 5 check boxes there would be 5 text boxes visible with the numbers 1 through 5 in the order that they were clicked.  I took a shot at this but only got the number 1 to appear over and over again.  I can't figure how to get a number to increment by 1 on this form.  Any help would be appreciated.  Thanks a bunch.
0
Comment
Question by:jakemail
[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
2 Comments
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1522397
i think there is a better way, but i dont have VB so i can't test it..

you can do something like this..

count=0
for i = 1 to controls.count
  if controls(i) is CheckBox and controls(i).visible then count=count+1
next i
currentedit.text=count

this is more of a pseudo-code...

..-=ViKtOr=-..
0
 
LVL 12

Expert Comment

by:jgv
ID: 1522398
If the variable 'cnt' is declared within the click event it will be reinitialized every time a check box is selected and the value would always be 1. Perhaps this is where you were experiencing a problem

Option Explicit
Dim cnt

Private Sub Check1_Click(Index As Integer)

If Check1(Index).Value = 1 Then
    cnt = cnt + 1
    Text1(Index).Text = cnt
    Text1(Index).Visible = True
End If

End Sub

0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
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…
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…
Suggested Courses

705 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