Changes

Form Events and Capabilities VB6

1,462 bytes added, 00:13, 15 February 2008
The following lines were added (+) and removed (-):
 == Write to control on another form and display ==  Dim lblCaught As Label  Set lblCaught = frmKaching.lblCaught  frmKaching.WindowState = vbNormal  lblCaught = "You've Been Naughty!"  frmKaching.Show == Determine is a form has been loaded ==The wrong way:  if form1.visible = true thenThe reason:Due to the way an intrinsic variable instance works in VB, the line above will actually cause form1 to load.  Forms are loaded automatically whenever referenced in code, whether loaded visibly or not.Special thanks to a gentleman named Steve Gerrard who posted a correct sample script on another forum.  His example works by going through a list of loaded forms and matching by the form name you are looking for.  Public Function FormIsLoaded(FormName As String) As Boolean    Dim oFrm As Form    For Each oFrm In Forms      If oFrm.Name = FormName Then        FormIsLoaded = True        Exit For      End If    Next oFrm  End Functionlovely! == Prevent Partially Painted Windows ==Sometimes when you display a form only some of the controls appear. After a pause the remaining controls appear. This does not have a professional look.  This has become much less apparent in VB 5.0 because of dramatic improvements in screen painting.example:  frmPerson.Show vbModeless  frmPerson.RefreshThe Refresh method will ensure that the form repainting is complete before executing any other code in the routine.
Bureaucrat, administrator
16,192
edits