Results 1 to 8 of 8

Thread: Very Basic Question --> Resolved

  1. #1

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519

    Smile Very Basic Question --> Resolved

    Hi all, How do I load, or call a form from a module?

    Rudy
    Last edited by RudyL; Jul 30th, 2004 at 12:54 PM.
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Something like this?
    VB Code:
    1. Dim f as New Form1()
    2. f.Show()

  3. #3

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Mike Hildner
    Something like this?
    VB Code:
    1. Dim f as New Form1()
    2. f.Show()
    Does that create a new form or load the form called form1?
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  4. #4
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    The first line does a couple things. It Dim's a variable named f as a type Form1. It also instantiates an instance of the class Form1, by calling the default, no argument constructor, and assigns that instance to the variable f.

    The second line shows the form. This would cause the form to fire it's Form1_Load method.

    Could also be written like this:
    VB Code:
    1. Dim f as Form1
    2. f = New Form1()
    3. f.Show()

  5. #5

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by Mike Hildner
    The first line does a couple things. It Dim's a variable named f as a type Form1. It also instantiates an instance of the class Form1, by calling the default, no argument constructor, and assigns that instance to the variable f.

    The second line shows the form. This would cause the form to fire it's Form1_Load method.

    Could also be written like this:
    VB Code:
    1. Dim f as Form1
    2. f = New Form1()
    3. f.Show()
    Ok.. Got it so far by changing the form name to the form I have.. (Don't know why but I was confusing my self with that) with this code:

    VB Code:
    1. Public Sub Main()
    2.  
    3.         Dim Splash As New Splash
    4.  
    5.         Call Splash.Show()
    6.  
    7.     End Sub

    Only problem is that the program ends right away and I only see the form for a brief second.. In VB6 I would do this:
    VB Code:
    1. splash.show vbmodal

    What is the equivilent to that in .NET?
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  6. #6
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    use a ShowDialog to show it modal. Also, I don't recommend you name your object the same as the class, that is confusing. At least call it oSplash

    Dim oSplash as Splash
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

  7. #7

    Thread Starter
    Frenzied Member RudyL's Avatar
    Join Date
    Mar 2001
    Location
    Chicago
    Posts
    1,519
    Originally posted by SeanGrebey
    use a ShowDialog to show it modal. Also, I don't recommend you name your object the same as the class, that is confusing. At least call it oSplash

    Dim oSplash as Splash
    I agree with that.. I only did it for a quick reference..

    Thanks for the ShowDialog.. That is exactly what I was looking for..


    Kind of irratating that I have to reference the form like that.. I liked it in VB6 where I create the form and then just call it anyplace..

    Thanks again for the help guys!
    10 different ways to skin a cat and amazingly enough each and every one has the same result, the cat gets skinned! The same can be applied to code, so be nice and accept each others "preferences".

  8. #8
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    VB6 actually created the reference for you behind the scenes, that's why you could do it in VB6. But that's really kind of sloppy and goes against things like encapsulation.
    Sean

    Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width