Results 1 to 4 of 4

Thread: Help with OOP Concept

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Help with OOP Concept

    I find myself with a lot of code (sub procedures) similar to the one below, which I know is not good. I think if I can be shown how this should be handled in an OOP world I can figure out how to do some of the other stuff in my applications OOP like (I am still trying to make the transition from Event driven programming to OOP).

    For instance, say I have two buttons to open two different reports. I want to eliminate the redundant code and only put the report name (the only variable) behind the button.

    I know this is not a very pratical way to handle opening multiple reports but I am only interested in getting the code into an OOP model.
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, _
    2.         ByVal e As System.EventArgs) Handles Button1.Click
    3.  
    4.         CrystalReportViewer1.ReportSource = _
    5.             "C:\testreport_Number1.rpt"
    6.         CrystalReportViewer1.RefreshReport()
    7.         CrystalReportViewer1.Show()
    8.  
    9.     End Sub
    10.  
    11.     Private Sub Button2_Click(ByVal sender As System.Object, _
    12.         ByVal e As System.EventArgs) Handles Button2.Click
    13.  
    14.         CrystalReportViewer1.ReportSource = _
    15.                "C:\testreport_Number2.rpt"
    16.         CrystalReportViewer1.RefreshReport()
    17.         CrystalReportViewer1.Show()
    18.  
    19.     End Sub

  2. #2
    Hyperactive Member Bloged's Avatar
    Join Date
    May 2001
    Location
    Rotterdam, The Netherlands
    Posts
    330
    Function:

    VB Code:
    1. Public Function CrystalReportViewer(ByVal sPath As String)
    2.         CrystalReportViewer1.ReportSource = sPath
    3.         CrystalReportViewer1.RefreshReport()
    4.         CrystalReportViewer1.Show()
    5. End Sub

    Call it with
    VB Code:
    1. CrystalReportViewer("C:\testreport_Number1.rpt")

    Grtz,

    Bloged

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    Thank you. That was very helpful.

    I remember that screen in you sig. How about a SYS64738 or a Load "Zork",8,1?

  4. #4
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    HI bloged,

    Re. your signature.

    The original ancestor of the Comodore 64k was the Comodore PET (Personal Electronic Transactor) which had just 4k of RAM. Boy, we had to be economic with code in those days!! It looked amazingly like a modern Desktop PC except that the keyboard was multi, translucent coloured! That was in the early '70 s.
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

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