catventure
01-12-2005, 15:25
Hi,
I do not think there is a way to display a listbox containing an array and have each item in the list consecutively numbered but I found it quite easy to create some code to do the job:
'code executed before showing strings in listboxes
'adds listnumber prefix to array elements for display purposes only
for i=1 to 500
verb(i)=ltrim$(str$(i)+". "+verb(i))
noun(i)=ltrim$(str$(i)+". "+noun(i))
deletion(i)=ltrim$(str$(i)+". "+deletion(i))
if i<101 then
charnoun(i)=ltrim$(str$(i)+". "+charnoun(i))
end if
if i<201 then
prep(i)=ltrim$(str$(i)+". "+prep(i))
objnoun(i)=ltrim$(str$(i)+". "+objnoun(i))
end if
next
'code after exiting listbox dialog
'removes listnumber prefixes from array elements
'and restores them to normal
for i=1 to 500
verb(i)=remove$(verb(i),ltrim$(str$(i))+". ")
noun(i)=remove$(noun(i),ltrim$(str$(i))+". ")
deletion(i)=remove$(deletion(i),ltrim$(str$(i))+". ")
if i<101 then
charnoun(i)=remove$(charnoun(i),ltrim$(str$(i))+". ")
end if
if i<201 then
prep(i)=remove$(prep(i),ltrim$(str$(i))+". ")
objnoun(i)=remove$(objnoun(i),ltrim$(str$(i))+". ")
end if
next
This works fine and will show each entry in the listbox preceded by a number like so:
1. word
2. word
3. word
.........etc.
although if I code it using a WHILE/WEND loop TB hangs and I have to exit using CRTL+ALT+DELETE.
I've probably coded it wrong somewhere -------->
'code executed before showing strings in listboxes
'adds listnumber prefix to array elements for display purposes only
for i=1 to 500
verb(i)=ltrim$(str$(i)+". "+verb(i))
noun(i)=ltrim$(str$(i)+". "+noun(i))
deletion(i)=ltrim$(str$(i)+". "+deletion(i))
while i<101
charnoun(i)=ltrim$(str$(i)+". "+charnoun(i))
wend
while i<201
prep(i)=ltrim$(str$(i)+". "+prep(i))
objnoun(i)=ltrim$(str$(i)+". "+objnoun(i))
wend
next
Anyway the first way is good enough for me and shows how to have numbered arrays in listboxes.
catventure.
I do not think there is a way to display a listbox containing an array and have each item in the list consecutively numbered but I found it quite easy to create some code to do the job:
'code executed before showing strings in listboxes
'adds listnumber prefix to array elements for display purposes only
for i=1 to 500
verb(i)=ltrim$(str$(i)+". "+verb(i))
noun(i)=ltrim$(str$(i)+". "+noun(i))
deletion(i)=ltrim$(str$(i)+". "+deletion(i))
if i<101 then
charnoun(i)=ltrim$(str$(i)+". "+charnoun(i))
end if
if i<201 then
prep(i)=ltrim$(str$(i)+". "+prep(i))
objnoun(i)=ltrim$(str$(i)+". "+objnoun(i))
end if
next
'code after exiting listbox dialog
'removes listnumber prefixes from array elements
'and restores them to normal
for i=1 to 500
verb(i)=remove$(verb(i),ltrim$(str$(i))+". ")
noun(i)=remove$(noun(i),ltrim$(str$(i))+". ")
deletion(i)=remove$(deletion(i),ltrim$(str$(i))+". ")
if i<101 then
charnoun(i)=remove$(charnoun(i),ltrim$(str$(i))+". ")
end if
if i<201 then
prep(i)=remove$(prep(i),ltrim$(str$(i))+". ")
objnoun(i)=remove$(objnoun(i),ltrim$(str$(i))+". ")
end if
next
This works fine and will show each entry in the listbox preceded by a number like so:
1. word
2. word
3. word
.........etc.
although if I code it using a WHILE/WEND loop TB hangs and I have to exit using CRTL+ALT+DELETE.
I've probably coded it wrong somewhere -------->
'code executed before showing strings in listboxes
'adds listnumber prefix to array elements for display purposes only
for i=1 to 500
verb(i)=ltrim$(str$(i)+". "+verb(i))
noun(i)=ltrim$(str$(i)+". "+noun(i))
deletion(i)=ltrim$(str$(i)+". "+deletion(i))
while i<101
charnoun(i)=ltrim$(str$(i)+". "+charnoun(i))
wend
while i<201
prep(i)=ltrim$(str$(i)+". "+prep(i))
objnoun(i)=ltrim$(str$(i)+". "+objnoun(i))
wend
next
Anyway the first way is good enough for me and shows how to have numbered arrays in listboxes.
catventure.