|
-
Mar 15th, 2004, 03:57 PM
#1
Thread Starter
Hyperactive Member
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:
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
CrystalReportViewer1.ReportSource = _
"C:\testreport_Number1.rpt"
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
CrystalReportViewer1.ReportSource = _
"C:\testreport_Number2.rpt"
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Show()
End Sub
-
Mar 15th, 2004, 04:36 PM
#2
Hyperactive Member
Function:
VB Code:
Public Function CrystalReportViewer(ByVal sPath As String)
CrystalReportViewer1.ReportSource = sPath
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Show()
End Sub
Call it with
VB Code:
CrystalReportViewer("C:\testreport_Number1.rpt")
Grtz,
Bloged
-
Mar 15th, 2004, 04:45 PM
#3
Thread Starter
Hyperactive Member
Thank you. That was very helpful.
I remember that screen in you sig. How about a SYS64738 or a Load "Zork",8,1?
-
Mar 15th, 2004, 07:25 PM
#4
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|