Hello,
My problem is I cannot select dynamically a line of a ListBox control with VBA code.
To be precise, I have a form called myForm, which contains a ListBox control called myListBox. This ListBox has multiple columns and only one line can be selected at a time.
If I click in myListBox, then I select a line which becomes highlighted. Everything normal.
Then, if I put this piece of code :
the previously selected line of myListBox is no more selected (highlighted)
If I modify slightly the code above with :
then I can get the 10th line selected and highlighted. But obviously, the 10th line is not necessarily the last line I selected, as you might guess.
This is where I point an issue : before executing the instruction myForm.Show, the property myListBox.ListIndex is well set to the last line I selected but there is no way to retrieve this state once the form displayed.
As a conclusion, this code :
highlights the 10th line.
But this code :
does not.
Has someone ever encountered this behavior?
I thank you very much in advance!
Bye,
Paulo
My problem is I cannot select dynamically a line of a ListBox control with VBA code.
To be precise, I have a form called myForm, which contains a ListBox control called myListBox. This ListBox has multiple columns and only one line can be selected at a time.
If I click in myListBox, then I select a line which becomes highlighted. Everything normal.
Then, if I put this piece of code :
Code:
[FONT=Helvetica]myForm.Hide[/FONT]
[FONT=Helvetica]// some instructions...[/FONT]
[FONT=Helvetica]// ...[/FONT]
[FONT=Helvetica]myForm.Show[/FONT]
If I modify slightly the code above with :
Code:
[FONT=Helvetica]myForm.Hide[/FONT]
[FONT=Helvetica]// some instructions...[/FONT]
[FONT=Helvetica]// ...[/FONT]
[FONT=Helvetica]myForm.myListBox.ListIndex = 10[/FONT]
[FONT=Helvetica]myForm.Show[/FONT]
This is where I point an issue : before executing the instruction myForm.Show, the property myListBox.ListIndex is well set to the last line I selected but there is no way to retrieve this state once the form displayed.
As a conclusion, this code :
Code:
[FONT=Helvetica]myForm.Hide[/FONT]
[FONT=Helvetica]// some instructions...[/FONT]
[FONT=Helvetica]// ...[/FONT]
[FONT=Helvetica]Dim myLine as Integer[/FONT]
[FONT=Helvetica]myLine = 10[/FONT]
[FONT=Helvetica]myForm.myListBox.ListIndex = myLine[/FONT]
[FONT=Helvetica]myForm.Show[/FONT]
But this code :
Code:
[FONT=Helvetica]myForm.hide[/FONT]
[FONT=Helvetica]// some instructions...[/FONT]
[FONT=Helvetica]// ...[/FONT]
[FONT=Helvetica]Dim myLine as Integer[/FONT]
[FONT=Helvetica]myLine = myForm.myListBox.ListIndex //myLine takes the right value[/FONT]
[FONT=Helvetica]myForm.myListBox.ListIndex = myLine[/FONT]
[FONT=Helvetica]myForm.show[/FONT]
Has someone ever encountered this behavior?
I thank you very much in advance!
Bye,
Paulo