Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a loop using text characters?

Status
Not open for further replies.

Gangrel

Programmer
Oct 18, 2001
49
CA
I was wondering if there was an easy way to loop through the alphabet so I could use it in an Access database I have.

We have stuff that is assigned a two char sequence, from AA to ZZ and 11 to 9Z. Sometimes, we remove stuff from the inventory (i.e. module GF maybe removed, thus freeing up that two letter sequence for us to use again)

What I'd like is a way to check for these 'hole's in the pattern. I was thinking of doing an SQL through VB, and looping it to check for each possible sequence's existance (ia. check for aa, then ab, then ac, etc.)

Is there an easy way to loop through a to z?

Or can you think of an easier way to check for what I want?

Thanks!
 
Hi

Dim i AS Integer
Dim char as String
' For A - Z
For i = 65 to 90
char = chr(i)
Next i
' For a to z
For i = 97 to 122
char = chr(i)
Next i

So assuming you have just uper case, and a two digit code
For i = 65 to 90
for j = 65 to 90
char = chr(i) & chr(j)
... whatever you want to do here
next j
next i
Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
kenneth.reaySPAMNOT@talk21.com
remove SPAMNOT to use
 
never tried in VBA but in C++ there is something like (free trial in VBA ;)

Public Sub MaakLoop()
Dim i, j As Integer
For i = 40 To 64
For j = 40 To 64
Debug.Print Chr(i) & Chr(j)
Next j
Next i
numbers for i and j are not right but look them up
instead of debug.print u have to do something like
result = dlookup(......,......,"[ID] = " & chr(i) & chr(j))
if nz(result) <> &quot;&quot; then
'store them in table of whatever
end if
think this helps
come back when it's not what u mean,

gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top