我有这个子程序来打开/关闭class _Countdown extends State<Countdown> {
int val = 3;
void countdown(){
CountDown cd = new CountDown(new Duration(seconds: 4));
cd.stream.listen((Duration d) {
setState((){
val = d.inSeconds;
});
});
}
@override
build(BuildContext context){
countdown();
return new Scaffold(
body: new Container(
child: new Center(
child: new Text(val.toString(), style: new TextStyle(fontSize: 150.0)),
),
),
);
}
}
的一些属性。
Application
假设有一个不同的应用程序实例我希望打开/关闭相同的属性,我如何能够修改此代码以接受参数/参数作为不同的应用程序? 我期待着类似的东西;
Public Sub OPTIMIZE_VBA(ByVal isOn As Boolean)
Dim bHolder As Boolean
bHolder = Not isOn
On Error Resume Next
With Application
.DisplayAlerts = bHolder
.ScreenUpdating = bHolder
.EnableEvents = bHolder
.Calculation = IIf(isOn, xlCalculationManual, xlCalculationAutomatic)
.Calculate
If .VERSION > 12 Then .PrintCommunication = bHolder
End With
On Error GoTo 0
End Sub
有了这个,我可以称之为;
Public Sub OPTIMIZE_VBA(ByVal isOn As Boolean, Optional ByVal ExApp As Excel.Application = thisApplication)
' rest of the code
End Sub
答案 0 :(得分:3)
一种方式:
Public Sub OPTIMIZE_VBA(ByVal isOn As Boolean, Optional ByVal ExApp As Excel.Application = Nothing)
If ExApp Is Nothing Then Set ExApp = Application
' rest of the code
End Sub
答案 1 :(得分:3)
Public Sub OPTIMIZE_VBA(ByVal isOn As Boolean, Optional ByVal ExApp As Excel.Application)
If IsEmpty(ExApp) Or ExApp Is Nothing Then
Set ExApp = Application
End If
' rest of the code
End Sub