Results 1 to 5 of 5

Thread: Module/Class (maybe) help

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    42

    Module/Class (maybe) help

    hi, could someone please tell me the correct way of doing this...

    As an example, I have a form with a few variables and a few buttons/labels etc on it. All i want to do is simple things such as on button click, change a variable value then update a label with the new value. Clearly this would be very easy to do by clicking on the button and adding the code directly to the click button event but several people will be working on different button click events so what I need to do is create additional vb files, then on the button click run the code within the additional file (but have the program treat the additional file as though the code was simply written in the button click event area so variables etc can still be accessed).

    I'm sure this can be done but have no idea how (being new to this...).

    I'm sorry if i have made little sence here, please let me know if you need further explanation. Many thanks to anyone who can help.

  2. #2
    Member
    Join Date
    Sep 2002
    Location
    Cincinnati, OH
    Posts
    44
    'Here you go...

    '1) Create a module called basMain and add it to your project.

    'In there, do this.

    Module basMain

    Public Function Stupid(ByVal txt As String, ByVal label As Label)
    label.Text = txt
    End Function

    End Module

    'In the button click event on the form, you would do:

    Stupid(TextBox1.Text, Label8)

    -----------------------------------------------------
    'TextBox1.Text is refering to a text box and label8 is referring to a lable. When you execute the command button, It takes the value in the text box and puts it into the label.
    Jim Webster

  3. #3
    Member
    Join Date
    Sep 2002
    Location
    Cincinnati, OH
    Posts
    44
    Oh, and stupid does not refer to you... Just thought I would clarify that.
    Jim Webster

  4. #4
    Frenzied Member
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    1,618
    Come on, this is 2004. Encapsulate that sucker in a class.
    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.

  5. #5
    Member
    Join Date
    Sep 2002
    Location
    Cincinnati, OH
    Posts
    44
    Yes, he is correct. If you are new at this though, try to create your module and do a simple call. Once you have done that, move to a class. You may want to invest in a book called Visual Basic.Net step by step. Would help you tremendously.


    Jim Webster - MCSD, MCSE
    Last edited by jwebster03; Jul 16th, 2004 at 12:33 PM.
    Jim Webster

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