Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB - hanging when finished

Status
Not open for further replies.

jojones

Programmer
Dec 4, 2000
104
AU
Not sure if I have done this exactly right. I have a form with a list box which I populate with data. I then show the form so the user can select from the listbox. The user will then click OK and a process will run using the selections from the listbox.

After the process is finished, VB seems to still be running the sub and although nothing is happening and no errors occurred, I need to press STOP before I can do anything else.

Does this make sense?

I am not sure that I have called the form correctly.

I used:
form1.visible = true
form1.show

is this wrong?

thanks
Jo
 
There are a couple of events in the form that are called before the form becomes visible (Initialize and load) when it does become visible the activate event is called (and is called each time the form receives the focus).
When you use form1.visible = true for the first time it will call the initialize and load events for you (step through your code) and the form will be shown. Calling the form.show event is redundant and no need to use both.

When the user hits the ok button do you set the visiblity or disable any controls (list1.enabled = false) and then not set the controls back to their usable state (list1.enabled = true)??

 
OK - I will take the form1.show out of the code.

When I press the OK button the user no longer needs the form. I run code which ascertains which of the items in the list box are selected and run a process for each one. THe form should then go away. I have not disabled any controls on the form, just Form1.hide and form1.visible = false

thanks
Jo
 
Oh. I have gone through my code and commented out lots of things. It seems that even without making the form visible, it hangs when I add the items to the listbox.

Is there something I have to do other than add the items? I read somewhere about having to set the List, ListCount and ListItem properties, but I don't know how to do this. WIll this make a difference?

Do
With Form1
FileCaptionOne = Rst![Month End File Caption One]
.PivotList.AddItem FileCaptionOne, pInt
Rst.MoveNext
pInt = pInt + 1
End With
Loop Until Rst.EOF

thanks
Jo
 
You need to unload the form, (after all code in Form1 is ran) and set it to nothing:

Unload Form1, or Unload Me
 
thanks a bunch. was no familiar with the unload form method.

Jo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top