VB.Net Class Design Question

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: VB.Net Class Design Question

Threaded View

  1. #1
    Join Date
    Nov 2003
    Austin, Texas

    VB.Net Class Design Question

    I've been working with a simple class library and a class that built. I was doing something that worked, but I broke it and now I cannot get it to work any longer. Some of the testing that I have been doing has shown me that I am missing something here, but I need to understand this. I think it is very simple, but I simply have never needed this before and I have not ran across in the past 4+ years of working in .Net.

    Here's the basic idea.

    Class Library contains a class, lets call it LOOKUP(). Lets say that the class is used for a phone book. The LOOKUP() method would have parameters to pass in such as that might be fname, mname, lname, address, city, state, zip, and phonenumber. Lets say that the class1 has a lookup mechanism where you can send in different parameters and the process will lookup the rest and return it to the calling code. That's sort of on the same level of what I am looking at in my app. It should be very simple.

    However, I am doing something a little odd. I cannot return the data using a dataset, datarow, xml, etc. I need to return the same parameters of the method that go in. So I need to return the fname, mname, lname, address, city, state, zip, and phonenumber using the same names as used in the method's parameters.

    Here's an example in VB.Net.

    Public Function LookUp(ByVal fname As String, ByVal mname As String, ByVal lname As String, ByVal address As String, ByVal city As String, ...

    What I did was to create properties for each of the these. Something like

    Public Property fname() as string
    Public Property mname() as string
    Public Property lname() as string

    This started to work, but then I realized that .Net was automatically hooking the property and the parameter up. So my guess is that there is a way that .Net can handle this, but I'm missing something.

    Can someone point me in the right direction here? Does .Net handle this sort of thing for you? I want to call a method with a given set of parameters, then have those parameters be accessed after the method has exited. Setting up properties seems to the be correct way to do this, but .net sync'd them for me. So I did not have to set them equal to each other in the code, and I was able to use the same name for the properties and the parameter.

    So my question is, did Microsoft set up something for this so the parameters and the properties could work together without having to do a lot of coding? It looks like they did, but I'm running into a few bugs with it. Are they supposed to automatically sync because they have the same name? That is what I want. I'm just hitting some bugs with this and I think I am setting up something incorrectly. What's the correct way to do this?

    Any suggestions would be appreicated.

    Best regards...
    Last edited by jrothlander; 07-01-2006 at 05:03 PM.

Similar Threads

  1. Replies: 0
    Last Post: 07-09-2005, 06:50 AM
  2. using a c# class in a vb.net webservice
    By Guillaume Lagac in forum ASP.NET
    Replies: 1
    Last Post: 05-21-2002, 02:50 PM
  3. question on best programming option
    By James in forum .NET
    Replies: 2
    Last Post: 03-28-2002, 07:14 AM
  4. Design Question
    By Sandoval Gonzalez in forum VB Classic
    Replies: 5
    Last Post: 11-09-2001, 04:29 PM
  5. EJB Design Question
    By Chad in forum Java
    Replies: 1
    Last Post: 09-28-2000, 04:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center