10-03-2001, 06:44 AM
Here is what I have and what I am doing the question is IS there a better way to gather the information that I need
I have a form with checkboxes , listboxes , textboxes in total around 225 items that the user can pick multiples of and I would like the information to be collected on a second form that they can copy and paste into another application that the user will be running.
This is a sample of the code that I am using at the moment:
if SMBuilder5.check_2attack.value = 1 then
text1.text = text1.text + (";skill 2_attack")
this is making the coding for just the one form around 690 lines of code
This is an offline mud building application.
MUD= multi user dungeon
Thank you in advance
10-03-2001, 06:57 AM
I would have a control array of each control type. Then read in the data from a file.
This would reduce your code to maybe 50 lines, reduce typos (since there is so much less code) and make it easier to maintain (just change the text file instead of changing the code and recompiling).
An example would be something like:
dim s as string, t as string
dim i as integer
s = vbnullstring
t = space$(200)
For i = 0 to 99 'assuming that there are 100 checkbox controls....
if smbuilder5.check(i) then
getprivateprofilestring "Messages","Check" & cstr(i),"",t,200,"monster.ini"
s = s & trim$( t)
text1.text = s
This assumes that the data is stored in an INI file for easy retrieval. Of course you will have to declare the GetPrivateProfileString API call (hint: encapsulate it in a function)
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
10-03-2001, 07:57 AM
so I would have to write that much code for each of the checkboxes ???
how would I gather the infomation from the textboxes to have that show on the second form. (This is user defined Infomation) nothing that could be hardcoded in the program
10-03-2001, 10:33 AM
No, you write that code once only. It goes through all 99 checkboxes. Basically, to access a control on another form, you prefix it with the name of the form eg:
This would print out the value of Check1 on Form1 to the debug window. This piece of code could be used by any form or module, and still work. It would always access the Check1 of Form1.
To access a textbox of Form1, you might try:
<pre>Debug.Print "The text input was: " & Form1.Text1.Text</pre>
Again, this can be used on any form/module.
10-03-2001, 01:34 PM
maybe I just am not suppose to get it
I would write a ini file with all of the information for each type of control (is this right so far)
and this type of call would cycle thru each of the checkboxes textboxes and listboxes and then would out put the info to the second form for me then
how would I set the ini files ....would I have a number for each of the items ?
and the textboxes are user defined like... the name of the mob would be various (could not be hardcoded)
I think I am starting to understand it but want to be sure first
Thank you for all of your help so far
10-03-2001, 02:30 PM
I think Bill might have been getting ahead of himself with the .INI file thing. The main way you will cut down your code is using a control array. Basically, instad of having controls:
Check1, Check2, Check3, Check4. Check5........... Check100
instead you use a control array.......
Check(1), Check(2), Check(3), Check(4) ........ Check(100)
Thus, you can easily check them in a loop:
<pre>Dim i As Integer
For i = Check.LBound To Check.Ubound
If Check(i).Value Then
Debug.Print "Checkbox " & i & " is checked!"
Debug.Print "Checkbox " & i & " is unchecked"
Thus you have looked at the value of every checkbox, which could be as many as you like theoretically (is there an upper limit?) with just a few lines of code. Of course, if every individual checkbox had to do something completely different, then you can't really shorten it that much. However, if the value of a checkbox merely dictates what text to write, then this can be taken from a lookup table or from a file (TXT i would suggest).
For the time being, just look into control arrays......