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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A bit of a tough programming challenge 1

Status
Not open for further replies.

Cndn

Programmer
Nov 22, 2001
22
0
0
CA
So, who knows a good way to create around 70 string variables without having to type code until your eyes bleed?
I'd love to know if there's a simple way. (loops maybe???)
 
Use an array and populate it with a loop. Think of it as an indexed Variable.

'------------------------------------------------
Dim strVar()

Sub Test()
Dim i As Integer
'Create them
For i = 0 To 70
ReDim Preserve strVar(i)
strVar(i) = "THIS is String Number " & i
Next i
'View them
For i = 0 To UBound(strVar)
MsgBox strVar(i)
Next i
End Sub
'--------------------------------------------------------
 
Of course, this 'works'.

But then it more-or-less defeats the point of having named variables you know- the convenience of having meaningful names of the thinnggys - which get a bit blurry when EVERYTHING is just [strVar(nn)].

Then too, the concept of just lumping everthing into a featureless morass of variants does not exactly provide the niciety of type checknig, so perhaps you could omit the option explicit statement and not use ANY declaration statements. This would save typing the 35 or so 'words' which create the featureless blob to begin with - increasing 'efficiency', decreasing the 'bloody finger' syndrome all while adding a great deal of mystery to the puzzle program.

Another consideration may be the 'bloody finger' syndrome, when you actually use the variables, as the use will (now) include the entry of the index (3 or 4 keystrokes) EVERY time you use it. So, it COULD be that the 'technique' is just an implementation of the 'pay-me-now or pay-me-later' syndrome.

In summary, my opinion is that the technique is really another example of a bad idea gone sadly awry. I -personally- have never suffered from the 'bloody finger' syndrome, but then (perhaps) the calluses from a year or more of actual programming has built up enough protection on my fingers to keep me safe through more than 70 declaration statements.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
May save on bloody fingers only to cause bloody headaches -good point and forewarning
 
Another positive post from MichaelRed to lighten up the atmosphere in this forum [yawn] Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top