473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Concatenating Variables In Loop

doma23
107 100+
I have this code:

Expand|Select|Wrap|Line Numbers
  1. For COUNT = 1 To 5
  2.     EmptyFields_Period [COUNT] = True
  3.     For Each ctl In Form_frmMain.Controls
  4.         If ctl.ControlType = acTextBox Then
  5.             If ctl.Tag = "Period" & COUNT Then
  6.                 If ctl <> "" Then
  7.                     EmptyFields_Period [COUNT] = False
  8.                 End If
  9.             End If
  10.         End If
  11.     Next ctl
  12. Next COUNT
What I'm trying to do is to set the boolean variables from EmptyFields_Period1 to EmptyFields_Period5 to TRUE at the beginning of the loop and then if certain conditions are met set it to FALSE, but posted code is clearly not a good syntax.
Tnx.
Jul 29 '10 #1

✓ answered by ADezii

@doma23
Try:
Expand|Select|Wrap|Line Numbers
  1. 'Initialize to True?
  2. EmptyFields_Period1 = True
  3. EmptyFields_Period2 = True
  4. EmptyFields_Period3 = True
  5. EmptyFields_Period4 = True
  6. EmptyFields_Period5 = True
  7.  
  8. For Count = 1 To 5
  9.   For Each ctl In Form_frmMain.Controls
  10.     If ctl.ControlType = acTextBox Then
  11.       If ctl.Tag = "Period" & Count Then
  12.         If ctl <> "" Then
  13.           Select Case Count
  14.             Case 1
  15.               EmptyFields_Period1 = False
  16.             Case 2
  17.               EmptyFields_Period2 = False
  18.             Case 3
  19.               EmptyFields_Period3 = False
  20.             Case 4
  21.               EmptyFields_Period4 = False
  22.             Case 5
  23.               EmptyFields_Period5 = False
  24.           End Select
  25.         End If
  26.       End If
  27.     End If
  28.   Next ctl
  29. Next Count

3 1961
ADezii
8,834 Expert 8TB
@doma23
Try:
Expand|Select|Wrap|Line Numbers
  1. 'Initialize to True?
  2. EmptyFields_Period1 = True
  3. EmptyFields_Period2 = True
  4. EmptyFields_Period3 = True
  5. EmptyFields_Period4 = True
  6. EmptyFields_Period5 = True
  7.  
  8. For Count = 1 To 5
  9.   For Each ctl In Form_frmMain.Controls
  10.     If ctl.ControlType = acTextBox Then
  11.       If ctl.Tag = "Period" & Count Then
  12.         If ctl <> "" Then
  13.           Select Case Count
  14.             Case 1
  15.               EmptyFields_Period1 = False
  16.             Case 2
  17.               EmptyFields_Period2 = False
  18.             Case 3
  19.               EmptyFields_Period3 = False
  20.             Case 4
  21.               EmptyFields_Period4 = False
  22.             Case 5
  23.               EmptyFields_Period5 = False
  24.           End Select
  25.         End If
  26.       End If
  27.     End If
  28.   Next ctl
  29. Next Count
Jul 29 '10 #2
doma23
107 100+
Ok, I was thinking about setting the variables to true before the loop, but then I still didn't know how would I change them to false inside the loop. Clearly, SELECT CASE is obvious solution that didn't come to my mind. Thank you! This solves my problem.

Just for the sake of knowing - what if there is 100 variables that need to be changed? Could it be done in some efficient way or would I need to use SELECT CASE 100 times?

BTW. I've read recently couple of your posts where you and Stewart were explaining how randomizer function really works. I was impressed by the knowledge, as well as by the collaboration with Stewart. It looked like synchronized swimming. :) Nice to 'officially' meet you. Cheers! :)
Jul 29 '10 #3
ADezii
8,834 Expert 8TB
@doma23
The pleasure is all ours!
Jul 29 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dont bother | last post by:
Hey, I have these attributes: index which is a numerical value value vector which is a numerical float value and I want to concatenate like this:
3
by: Bill | last post by:
I have a page that contains processed variables that I'd like to forward using the response.redirect method. However, because the response.redirect contains the page within "pagename.asp", I have...
6
by: nwheavyw8 | last post by:
I am currently trying to write a simple PHP script that will split an uploading file up into 500kb "chunks", then read and concatenate them back together when accessed for download. I can't seem...
16
by: Dixie | last post by:
I have a problem using Dev Ashish's excellent module to concatenate the results of a field from several records into one record. I am using the code to concatenate certain awards onto a...
4
by: Juan | last post by:
Does any one know if there are reported bugs when concatenating strings? When debugging each variable has the correct value but when I try to concatenate them some values are missing (I canīt see...
1
by: Daniel Martini | last post by:
Hi all, I'm currently coding some functions in plpgsql for generating reports out of records in a table. Problem is: NULL values in records make the complete function fail. Here is a simple...
11
by: Girish Sahani | last post by:
I wrote the following code to concatenate every 2 keys of a dictionary and their corresponding values. e.g if i have tiDict1 = tiDict1 = {'a':,'b':} i should get tiDict2={'ab':} and similarly for...
21
by: c | last post by:
Hi everybody. I'm working on converting a program wriiten on perl to C, and facing a problem with concatenate strings. Now here is a small program that descripe the problem, if you help me to...
5
by: Patrick | last post by:
Hi all, In my SQL procedures in DB2 8.2, I current declare several cursors that return select statements with 10 columns in it. As a result, assigning host variables becomes a coding mess, as...
3
by: banderson | last post by:
Hello all, I have a table "tblContacts" that holds my Contact Info. Because there can be multiple Contact Types for a Contact, I have a second table "tlnkContactTypes" in which there is a record for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.