Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: Re:Parametric FormLoading


Message #1 by "Dafna" <dafnal@m...> on Sat, 20 Oct 2001 22:00:58 +0200
hi everyone
hi Eva and Andy

both of you have given an impressive looking procedure.
if i may, i would like to add a few more things, actually modify the 
existing code so that it looks a lot cleaner.  as i understand as far as 
possible keep the exit sub call to the end as you know the complete 
cycle of the procedure.

my suggestions are :

private sub showForm(sFrm as String)
dim xx as integer, frm as Form

for xx=3D0 to forms.count-1
    if forms(xx).Name =3D sFrm then
        exit for
    endif
next
if xx > forms.count-1 then
    forms.Add sFrm
    set frm =3D Forms(Forms.count-1)
else
    set frm =3D Forms(xx)
end if
frm.Show
Me.Hide

end sub

hope you like the style
*****************************************
BHARAT SABOO
BHAMINI SABOO

503/504, Mount, J.P. Road, Versova
Mumbai - 400061.

bharatsaboo@y...
*********************************************
  ----- Original Message -----
  From: Zadoyen, Eva
  To: professional vb
  Sent: Tuesday, October 23, 2001 7:13 PM
  Subject: [pro_vb] Re:Parametric FormLoading


  Andy,
  Very impressive ! I couldn't think of this way of loading the form.
  Just to make sure that form is not loaded already - need to add some
  checking procedure:


  ************************************
  Private Sub ShowForm(sFrm As String)
  dim frm as form
  dim bLoaded as boolean
  bLoaded =3DFalse   ' I know - it's by default - just for illustration

  'Include this part in the code:

  For each frm in Forms
  if frm.Name =3D sFrm  then
  bLoaded =3D vbtrue
  frm.Show
  exit for
  end if
  next frm
  ' load form
    if not bLoaded then
  Forms.Add sFrm
  ' get the last form to be loaded ie. the one we are intersted in
  Set frm =3D Forms(Forms.Count - 1)


  ' show the form
  frm.Show
    END IF
  'hide calling form
    Me.Hide
  Exit Sub

  Eva

  -----Original Message-----
  From: andy irvine [mailto:andy@e...]
  Sent: Tuesday, October 23, 2001 7:05 AM
  To: professional vb
  Subject: [pro_vb] Re:Parametric FormLoading


  Dafna, Marco,

  This should work:

  Private Sub ShowForm(sFrm As String)
  dim frm as form

  ' load form
  Forms.Add sFrm
  ' get the last form to be loaded ie. the one we are intersted in
  Set frm =3D Forms(Forms.Count - 1)
  'hide calling form
  Me.Hide
  ' show the form
  frm.Show

  Exit Sub

  HTH
  andy


  > I am curious to know if it is possible to do this.
  > What I am doing right now is a big select statement,
  > something like:
  >
  > Select Case strFormName
  > case "frmA"
  >     frmA.Show
  > case "frmB"
  >     frmB.Show
  > ..etc etc
  > end select
  >
  > that is not elegant, but it works.
  >
  > m.
  >
  >
  >
  > -----Original Message-----
  > From: Dafna [mailto:dafnal@m...]
  > Sent: Saturday, October 20, 2001 1:01 PM
  > To: professional vb
  > Subject: [pro_vb] Re:Parametric FormLoading
  >
  >
  >
  > Hi,
  > I want to link a popup menu item to a form. Since it is suppose to 
be =3D
  > Parametric, the form name is not hard-coded. Therefore, I want a 
form to
  =3D
  > be loaded, by sending its name as  a parameter.
  > Is it possible? and how?
  >
  > Thanks,
  >
  > Dafna.
 

  Return to Index