Results 1 to 6 of 6

Thread: Open a Form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954

    Open a Form

    I am trying to make the move from vb6 to vb.net. How do you call a form that you have in your project. This is the the I want to do. I have two forms, when someone clicks on a text box in one form I want to populate another form with some strings and display it. For the life of me I can't see how to do this.

    Thanks.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If you want to make it mandatory that info gets passed in order to display the form then you can add the data as parameters to the New() method of the form and add your code to the bottom of it. Otherwise you can make override the New() method with the parameters so you can use either or. If you override the Constructor (New) then make sure and call the original one first either with:

    New()

    'or

    MyBase.New()

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    You the man Ed, could you post a little example code?

  4. #4
    New Member
    Join Date
    Aug 2002
    Location
    Malaysia
    Posts
    4

    Try this

    coding in button:

    Dim frm1 As form
    frm1=new formA(b)
    frm1.show


    coding in form you want to call:

    (Click the "Windows Form Designer generated code" first)
    Dim test As string
    Public sub new(ByVal a As String)
    MyBase.New()
    test=a




    "b" is a value you want to send to the form you call.
    "a" receive value "b".

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    SO this part:

    coding in button:

    Dim frm1 As form
    frm1=new formA(b)
    frm1.show


    Goes into the form where I am trying to call the form?

    And this part:
    (Click the "Windows Form Designer generated code" first)
    Dim test As string
    Public sub new(ByVal a As String)
    MyBase.New()
    test=a

    Goes into the form I am trying to call? If so where?

  6. #6
    New Member
    Join Date
    Aug 2002
    Location
    Malaysia
    Posts
    4

    Smile try again

    Double-click the form u want to call, u can see coding.
    You can find the coding (almost) like this :



    Public Class formA
    inherits System.Windows.Forms.Form

    + Windows Form Designer generated code




    After click + at " + Windows Form Designer generated code "
    you can see this coding:

    Public sub new()
    MyBase.New()


    try to change to :


    Dim test As string
    Public sub new(ByVal a As String)
    MyBase.New()
    test=a

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