Question : oop

Warning: Missing argument 1 for Something::Something(),



want to edit so these lines work

$obj=new Something(); // x=3 and y=5
$obj=new Something(8); // x=8 and y=5
$obj=new Something(8,9); // x=8 and y=9

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
<?php

class Something {
var $x;

function Something($y) {
$this->x=$y;
}

function setX($v) {
$this->x=$v;
}

function getX() {
return $this->x;
}
}



$obj=new Something(6);
function Something($x="3",$y="5"); 

$obj=new Something(); // x=3 and y=5
$obj=new Something(8); // x=8 and y=5
$obj=new Something(8,9); // x=8 and y=9 



?>

Answer : oop


I wrote the following code for another problem, i have taken out the unnecessary stuff, I believe this is a much better way to approach opening the said workbook, then closing it, then quitting excel

notice the private function at the bottom, also this assumes you will add a reference to excel in the project and also use Imports Excel = microsoft.blah.blah.blha

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
Dim excelApp As Excel.Application
        Dim WB As Excel.Workbook
        Dim workbookName As String = "Test Workbook Name"

        'open Excel to minimized state
        excelApp = New Excel.Application()
        excelApp.Visible = CBool(Microsoft.Office.Core.MsoTriState.msoTrue)
        excelApp.WindowState = Excel.XlWindowState.xlMinimized

        'open workbook
        WB = excelApp.Workbooks.Open(workbookName, Microsoft.Office.Core.MsoTriState.msoFalse, _
                                     Microsoft.Office.Core.MsoTriState.msoFalse, _
                                     Microsoft.Office.Core.MsoTriState.msoTrue)
	
	WB.close
	excelApp.quit

        'need to release these com objects or they may remain open in the running services
        ReleaseObject(excelApp)
        ReleaseObject(WB)
        ReleaseObject(WS)
        ReleaseObject(target)

        excelApp = Nothing
        WB = Nothing
        WS = Nothing
        target = Nothing
        'Erase targetArray

        'run garbage collector
        GC.Collect()

    Private Sub ReleaseObject(ByVal o As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
        Catch ex As Exception
        Finally
            o = Nothing
        End Try

    End Sub
Random Solutions  
 
programming4us programming4us