Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Array - delete and replace elements

Good day Group,

Need some help regarding 1 dimensional arrays. Are building an array
where
the elements are selections made in a multi listbox. Trying to find a
way to delete
an element in the array if it is deselected in the listbox then insert
a new
selection into the same place where the deselected element was.This
question
might be to inprecise to answer but are grateful for some hints. Or is
there a
better way to build a string by a listbox that can be manipultaed the
same way?

Bgds

CG Rosén
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Array - delete and replace elements

kalle expressed precisely :
Good day Group,

Need some help regarding 1 dimensional arrays. Are building an array
where
the elements are selections made in a multi listbox. Trying to find a
way to delete
an element in the array if it is deselected in the listbox then insert
a new
selection into the same place where the deselected element was.This
question
might be to inprecise to answer but are grateful for some hints. Or is
there a
better way to build a string by a listbox that can be manipultaed the
same way?

Bgds

CG Rosén


Are you trying to assemble a longer string by selecting shorter string
components? If so, I'd rather use a textbox to display the result so
users can see it 'as they build'. In this case you need to query the
listbox selection (checked/unchecked) to determine whether to
add/remove/replace in the result string. I'd not go that way! Instead,
I would not use a checked list for reasons I'll explain below.

Also, there needs to be a way of delimiting each substring in the
result. I'd probably use a space character so the result builds like a
sentence or statement, though I wouldn't include the space at the end
of the substrings in the listbox. I'm thinking to add the space before
inserting new substrings.

Remove/replace can be handled easily so the delimiter spaces get
handled correctly. This precludes, then, that your Userform has
separate buttons for each action (AddRemoveReplaceCancelDoneExit).
I'd probably code it so the user could select where to add substrings
in the textbox, but that could create problems if they choose within an
existing substring. In any event, remove/replace could be handled by
selecting in the textbox, in the listbox, or a combination of the two
in the case of replace.

The AddRemoveReplace buttons would merely set a 'Mode' variable so
the subsequent action will be processed accordingly. (This is why I
would not use a checked list) For example:

To Add a substring:
Select the position in the textbox AND/OR select the substring in the
listbox. Click the 'Add' button.

If the position is selected in the textbox then clicking the substring
in the listbox inserts the text at that position, Else it appends it to
the end of the assembled string.


To Remove a substring OR text from the textbox:
Select the substring in the listbox OR select the text in the textbox.
Click the 'Remove' button.

If there's a match for the listbox substring in the textbox then the
text is removed along with its leading space (..if there is one). If
text in the textbox is selected then that text is removed.


To replace text in the textbox with a substring from the listbox:
Select the text in the textbox, then click the 'Replace' button, then
select the substring in the listbox.


To edit directly in the textbox, just click the position to insert and
start typing.


The 'Cancel' button escapes the current action.

The 'Done' button processes the text in the textbox and clears all
action modes. Only click this button when you're done building your
result string. You could name it 'Process' if that term is more clear
to you or your users.

The 'Exit' button aborts all pending actions and unloads the userform.
If you want to process the textbox text before exiting then the 'Done'
button must be clicked.

HTH

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Array - delete and replace elements

On 17 Apr, 21:52, GS wrote:
kalle expressed precisely :





Good day Group,


Need some help regarding 1 dimensional arrays. Are building an array
where
the elements are selections made in a multi listbox. Trying to find a
way to delete
an element in the array if it is deselected in the listbox then insert
a new
selection into the same place where the deselected element was.This
question
might be to inprecise to answer but are grateful for some hints. Or is
there a
better way to build a string by a listbox that can be manipultaed the
same way?


Bgds


CG Ros n


Are you trying to assemble a longer string by selecting shorter string
components? If so, I'd rather use a textbox to display the result so
users can see it 'as they build'. In this case you need to query the
listbox selection (checked/unchecked) to determine whether to
add/remove/replace in the result string. I'd not go that way! Instead,
I would not use a checked list for reasons I'll explain below.

Also, there needs to be a way of delimiting each substring in the
result. I'd probably use a space character so the result builds like a
sentence or statement, though I wouldn't include the space at the end
of the substrings in the listbox. I'm thinking to add the space before
inserting new substrings.

Remove/replace can be handled easily so the delimiter spaces get
handled correctly. This precludes, then, that your Userform has
separate buttons for each action (AddRemoveReplaceCancelDoneExit).
I'd probably code it so the user could select where to add substrings
in the textbox, but that could create problems if they choose within an
existing substring. In any event, remove/replace could be handled by
selecting in the textbox, in the listbox, or a combination of the two
in the case of replace.

The AddRemoveReplace buttons would merely set a 'Mode' variable so
the subsequent action will be processed accordingly. (This is why I
would not use a checked list) For example:

To Add a substring:
Select the position in the textbox AND/OR select the substring in the
listbox. Click the 'Add' button.

If the position is selected in the textbox then clicking the substring
in the listbox inserts the text at that position, Else it appends it to
the end of the assembled string.

To Remove a substring OR text from the textbox:
Select the substring in the listbox OR select the text in the textbox.
Click the 'Remove' button.

If there's a match for the listbox substring in the textbox then the
text is removed along with its leading space (..if there is one). If
text in the textbox is selected then that text is removed.

To replace text in the textbox with a substring from the listbox:
Select the text in the textbox, then click the 'Replace' button, then
select the substring in the listbox.

To edit directly in the textbox, just click the position to insert and
start typing.

The 'Cancel' button escapes the current action.

The 'Done' button processes the text in the textbox and clears all
action modes. Only click this button when you're done building your
result string. You could name it 'Process' if that term is more clear
to you or your users.

The 'Exit' button aborts all pending actions and unloads the userform.
If you want to process the textbox text before exiting then the 'Done'
button must be clicked.

HTH

--
Garry

Free usenet access athttp://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc- Dölj citerad text -

- Visa citerad text -


Hi Garry,

Thanks for your detailed answer, I will work along your suggestions.

CG Rosén
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete row/s with the same elements as the above row Arno Excel Programming 5 November 25th 08 08:33 AM
Delete row with the same elements as the one above Arno Excel Programming 3 November 24th 08 05:40 PM
elements in an array Chip Pearson Excel Programming 2 November 23rd 07 12:19 PM
elements in an array Alan Beban[_2_] Excel Programming 0 November 21st 07 08:21 PM
conditionally delete some elements from an array clui[_8_] Excel Programming 1 December 4th 03 01:21 AM


All times are GMT +1. The time now is 04:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"