|
-
Jul 18th, 2000, 08:12 AM
#1
Thread Starter
Lively Member
weird variables
say i have option1, option2, option3...all the way to option10
how do i increment the variable name, i tried:
Code:
for j = 1 to 10
option[j].text = ""
next j
but that sort of thing doesnt work. ne ideas?
[Edited by Mag-Net on 07-18-2000 at 09:16 AM]
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jul 18th, 2000, 08:23 AM
#2
Addicted Member
Hi,
is it still time to reconcider things like using a
collection for option1 to 10 or you are stuck with the
way it is ?
Another way to do so ( if you don't have tons of controls on your form) is to loop for each control in the form and if
the control type or name is correct, do what you want to
do... Do you know what I mean ? If not, reply this post
for sample code...
-
Jul 18th, 2000, 08:42 AM
#3
Fanatic Member
What you need is a Control Array instead of 10 seperately named controls.
So you would have a control named optButton appear on your form 10 times each with a differnt index (1-10).
Then you could use the following
Code:
Dim intCount as Integer
For intCount = 1 To 10
optButton(intCount).Text = ""
Next intCount
-
Jul 18th, 2000, 09:14 AM
#4
Thread Starter
Lively Member
no i need it like it is, they are called txtOption1 and so on, they link to a database with the names as Option1 and so on, i have got a function to strip the txt off it and return the name that would be in the database, that is y i cant have a control array. ne ideas now?
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
-
Jul 18th, 2000, 09:23 AM
#5
Fanatic Member
Try this ...
Code:
Dim ctl As Control
For Each ctl In Me
If InStr(ctl.Name, "Option") Then
ctl.Text = ""
End If
Next ctl
-
Jul 18th, 2000, 09:23 AM
#6
Fanatic Member
You can still use the control array.
Use the long forgotten, and underused (in my opinion) Tag property of each option button. Store the relevant database name in the Tag.
Or strName = optionArray(index).Name & cstr(index)
Iain, thats with an i by the way!
-
Jul 18th, 2000, 11:25 AM
#7
Addicted Member
Controls are held in a Collection referreced by Index Number or name. Why not build a string appended with the number then such as :
Controls("Command1").Top
Then you can use something like this:
Dim MYCONTROL As Control
For Each MYCONTROL In Controls()
Debug.Print MYCONTROL.Name
If TypeName(MYCONTROL) = "TextBox" Then
etc..
Bit sketchy this but I'm off home now....
-
Jul 18th, 2000, 11:13 PM
#8
Fanatic Member
I Just Wanted To Say Hear Hear to Iain17 as lotsa guys ask what the tag properties for etc (roflmao)
And now its got so i just say, its for hanging your coat on when you get into the office.
DocZaf
{;->
-
Jul 19th, 2000, 12:13 AM
#9
Junior Member
I think the easiest way to do this would be to have a thing as following:
Controls
Option(?) {10 options in arrary 0 to 9}[? = number of options needed in arrary]
Code:
dim stro(option.lbound to option.ubound)
private sub from_load()
stro(0) = "{what ever you want option(0) to be}
.
.
.
stro(9) = "{what ever you want option(9) to be}
end sub
Get the point? That would be the easiest way to store it.
Now, the reading part:
Code:
private sub option_click
if stro(index) = "What ever" then
'do this
elseif stro(index) = "This" then
'do this code
.
.
.
end if
end sub
That should do it for you. The stro is an arrary with the same number of items as the options. Then during form load you set each index of stro to what you want that options code to be.
-
Jul 19th, 2000, 04:11 PM
#10
Thread Starter
Lively Member
kule idea thanks, i will add that to my next revision of the program, thanks I like your ideas about the tag property, and agree that many ppl dont know what it is or how to use it etc. Ah well, they may learn.... enjoy
Mag-Net's Home
Visual Studio 6-Enterprise - SP4
ICQ: 35519773
Have Fun 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|