Results 1 to 2 of 2

Thread: Should I create a Control Class rather than use a Module for MVC?

  1. #1

    Thread Starter
    Hyperactive Member capsulecorpjx's Avatar
    Join Date
    May 2005
    Location
    Renton, WA
    Posts
    288

    Should I create a Control Class rather than use a Module for MVC?

    So I'm a little new to MVC. I'm trying to use it in writing VB.NET Windows Form code.

    So I'm thinking, instead of using a VB.NET module, or having code embedded in the forms, I should create my own "Control" Class, to handle all operations and "application" level variables.

    Is this the right approach?

    Ex:
    Code:
     Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
       goControl = New MyControlClass()
       goControl.sUserID = txtUser.text
       goControl.sPass = txtPass.text
       goControl.login()
       
       Dim lfTemp as New frmMainForm
       lfTemp.show()
       me.Close()
    End Sub
    "I like to run on treadmills, because at least I know I'm getting nowhere."
    - Me

  2. #2
    Fanatic Member proneal's Avatar
    Join Date
    May 2011
    Posts
    762

    Re: Should I create a Control Class rather than use a Module for MVC?

    vb Code:
    1. Dim goControl as myControlclass
    2.  
    3. goControl = New MyControlClass()
    4.    goControl.sUserID = txtUser.text
    5.    goControl.sPass = txtPass.text
    6.    goControl.login()
    7.    
    8.    Dim lfTemp as New frmMainForm
    9.    lfTemp.show()
    10.    me.Close()

    Looks alright to me. Using classes is an OOP/OOD way to go with .Net
    Oh, I added a declaration that then is followed by instantiating a NEW class of the Usercontrol.
    You prob already added that elsewhere though, eh?

    Good LUCK!~

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