Results 1 to 5 of 5

Thread: VB.NET Newbie

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    12

    VB.NET Newbie

    I previous projects I used Module.bas to handle most of my code. In VB.NET How do I call these from my forms. For an example

    I have a Module called Main.bas and Something.bas. In VB6 I used

    Main.DoSomething()
    Sonething.AnotherThing()

    Also, when I refer to textboxes on the form from the Module I used.

    Form1.Textbox1.text = "Hello World."

    How would I handle these two examples. Thanks in advance.

  2. #2
    Member
    Join Date
    Apr 2004
    Location
    Millbrae, CA
    Posts
    48
    Modules are still around in VB.NET, but they have the file extension .vb (Main.vb). To call functions inside your form code, you can just refer to the function name.

    For example, if you have a function called DoSomething() in your module, and want to call it just type DoSomething(). No need to refer to the module.

  3. #3
    Junior Member
    Join Date
    Apr 2004
    Posts
    19
    but make sure you declare your function in your bas module at least as Friend
    www.mod2software.com
    Home of the VB.NET Class Builder Utility - Demo and Full versions available now!

  4. #4
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    to reference another control or another form from your module, you have to declare a variable as that form....

    dim form1 as MyMainForm

    then, whatever you do to form1 is actually done to MyMainForm

    to change the text of a textbox on MyMainForm for example, do this

    VB Code:
    1. dim DummyForm as TheMainForm
    2.  
    3. dummyForm.TextBox1.text = "Van Halen is back, baby!!"

    the thing to watch for is scope. read up on that in your help files.
    another thing is to not declare it as NEW. that actually creates a new instance of that form and your main one never gets altered.

    hope that helps!!

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    12

    Thanks

    Thanks to all who replied. This will give me the start I need to move from VB6 to VB.NET.

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