borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (image comparsion)Next Topic (Video API call & 'delay' video buffer) New Topic New Poll Post Reply
AndreaVB Forum : API : How to create a start page
Poster Message
dchildress
Level: Guest


icon How to create a start page

I am trying to make a program user friendly.  I want the user to be able to determine what midi form they would like to open when they login to a program.  I can save the form name to a database. However, I can not dynamically load the form using a variable.  It works if I use a select statment.  However, that is very messy and I have to update the case when I add a form. My code looks like this

Private Sub MDIForm_Load()
‘ get form name to load for users logged in
dataenv.getformname frmmain.userid
if isnull(dataenv.rsgetformname!formname) = false then   ‘ user has set a default form
dim homepage as form
set homepage= dataenv.rsgetformname!formname
homepage.show
dataenv.rsgetformname.close
else
dataenv.rsgetformname.close
end if

end sub
  

18-12-2002 at 03:11 AM
| Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: How to create a start page

The select case (and similar methods) would be the only way, and you'd have to update it whenever you add a new form regardless.

(as a note, I wouldn't be using a data environment to retrieve the data anyway, use variables)

18-12-2002 at 04:07 AM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: How to create a start page

what do you guys mean by having to update the select statement everytime a form is added?

do you mean that in coding the program?


____________________________
Been busy trying to take a second degree <--it's not working out...

18-12-2002 at 05:26 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: Re: How to create a start page

quote:
vbgen wrote:
what do you guys mean by having to update the select statement everytime a form is added?

do you mean that in coding the program?




Like This:

    Select Case FormName
        Case "Form1"
            Form1.Show
        Case "Form2"
            Form2.Show
    End Select


Whenever a new form is added, the name has to be added to the select case statement.

____________________________
Everywhere's Local (classifieds, job postings, & more for everycity in the world - user entered)
18-12-2002 at 08:19 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: How to create a start page

okay..

i got it...

well, if that's the case, can't we create a function to handle this kind of updating?

or does it sound unnecessary?

____________________________
Been busy trying to take a second degree <--it's not working out...

18-12-2002 at 09:35 PM
View Profile Send Email to User Show All Posts | Quote Reply
JLRodgers
Level: Moderator

Registered: 04-04-2002
Posts: 1616
icon Re: How to create a start page

That's the thing, no matter how it's done, you have to update the code with all new forms that are added (which is what dchildress was trying to aviod).

Of course it's only annoying during the first stages when new forms are added frequently. Towards the final version, few to no modifications are (normally) made to form names, so few changes are normally needed.

The only way no to use a select case would be (although NOT a good idea, and normally not even possible):

1) Load ALL forms that can be the startup form
2) Loop through all the forms, making the one that's the desired start form visible.


' To load a form
'    Load frmMain
'    Load frmForm1
'    etc for all possible startup forms

' Assuming all forms are loaded
    Dim fForm As Form

    For Each fForm in Forms ' Forms being all loaded forms
        If fForm.Name = strStartupForm Then
            fForm.Visible = True
        End If
    Next


the catch here is, normally any code that's in the Form_Activate or Form_Load (or anything similar that's done at loading) has to be removed/moved otherwise everything will be run when the form's loaded. Any .Visible events in the form that run when loaded/activated have to be removed...

18-12-2002 at 10:02 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
vbgen
Level: Moderator

Registered: 10-10-2002
Posts: 876
icon Re: How to create a start page

additional help i hope..

if that's the case, then i suggest that all the code in each form's load or activate event be placed inside a sub, whether private or public...

i'll post back and give code samples.
please be a little patient.

thansk,.

____________________________
Been busy trying to take a second degree <--it's not working out...

19-12-2002 at 03:19 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : API : How to create a start page
Previous Topic (image comparsion)Next Topic (Video API call & 'delay' video buffer) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder