Solved

Determining the index of current control in array

Posted on 2001-06-20
9
250 Views
Last Modified: 2010-04-17
I have 2 arrays - one holding a "beginning" 9 digit number, the other holding an ending 9 digit number.  When the user hits ENTER or TAB, I would like the first 7 digits from the beginning number to appear in the ending number box.  I can make the code work if I use individual textboxes but since this is an array, it's a bit different.  How do I determine the item number of my current control in the array?  What I would like is this:

Beginning                      Ending
123456789 - HIT TAB OR ENTER - 1234567
998879988 - HIT TAB OR ENTER - 9988799
0
Comment
Question by:Silvey
9 Comments
 
LVL 4

Expert Comment

by:prashant_n_mhatre
ID: 6212353
Which langauge man? VB?
0
 

Author Comment

by:Silvey
ID: 6212364
Visual Basic - SORRY!
0
 

Author Comment

by:Silvey
ID: 6212469
Visual Basic - SORRY!
0
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 6212916
I don't understand. Do you have a control array, a numeric array, or both? If you have a control array, the index of the control will be given to you in the event parameters, eg Text1_LostFocus(Index As Integer).

Zaphod.
0
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.

 
LVL 22

Expert Comment

by:CJ_S
ID: 6213209
Can you make a small list of what element are on the screen, what kind of array you have, and where the data is actually coming from. That will help quite a bit...

Regards,
CJ
0
 

Author Comment

by:Silvey
ID: 6214475
I have 2 arrays of textboxes; array 1 = BEGINNINGIDs, array 2 = ENDINGIDs.  The user keys a "beginning id" which is a 9 digit number then hits TAB or ENTER (which takes them to the ending id box).  After entering the beginning id, when the user hits ENTER or TAB, I would like the first 7 digits from the beginning id to appear in the ending id box.
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 50 total points
ID: 6214661
Create 2 textboxes with the same name (Text1)
Create another 2 textboxes with the same name (Text2)

Add the following code to your application:

Private Sub Text2_GotFocus(Index As Integer)
    Text2(Index).Text = Left(Text1(Index).Text, 7)
End Sub

Regards,
CJ
0
 

Author Comment

by:Silvey
ID: 6214977
Thank you, CJ!  I thought that I had to explicitly reference the index...I didn't realize that just using INDEX was sufficient!
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 6215789
Glad to be of service!

Regards,
CJ
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 know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

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