DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Victoria Guest

    Kenny..question about your vb.net method


    Kenny,
    >As a side note:
    >
    >The practice of accessing controls directly from another form will not work
    >in VB.Net. A better approach would be something like this:
    >
    >In frmPrint:
    >
    >Public Property Get UseCurrent() As Boolean
    > UseCurrent = optCurrent.Value
    >End Property
    >
    >Public Property Let UseCurrent(ByVal bValue As Boolean)
    > If bValue = True Then
    > optCurrent.Value = True
    > Else
    > optList.Value = True
    > End If
    >End Property
    >
    >This approach has (at least) two advantages:
    >
    >1. It will also work in VB.Net (after running it through the upgrade wizard).
    >2. If you switch from one type of control to another, you only have to

    change
    >code in one place.
    >
    >
    >--Kenny

    Thanks I got it working by using the method you provided, the non VB.NET
    method. But I had a question about the VB.NET method. Looking at your code
    above wouldn't I need to put frmPrint.optCurrent.Value instead of just optCurrent.Value
    . Isn't that similar to what I'm doing in vb6?? I tried your code with just
    optCurrent.Value but I get an object required error because it doesn't know
    what it is.

    Vic


  2. #2
    Kenny Acock Guest

    Re: Kenny..question about your vb.net method


    Victoria,

    >Thanks I got it working by using the method you provided, the non VB.NET
    >method. But I had a question about the VB.NET method. Looking at your code
    >above wouldn't I need to put frmPrint.optCurrent.Value instead of just

    optCurrent.Value
    >. Isn't that similar to what I'm doing in vb6?? I tried your code with just
    >optCurrent.Value but I get an object required error because it doesn't

    know
    >what it is.


    That code should be in frmPrint, not frmMain. The Property Get and Property
    Let together create a property for frmPrint. If you put the Property Get
    and Property Let in frmMain, it would be a property of frmMain, not frmPrint.
    To get it to work, place the code in frmPrint. Then in frmMain you can
    do this:

    In frmMain:

    If frmPrint.UseCurrent = True Then
    'So Something
    End If

    --Kenny

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links