Vbscript用于单个返回语句的多个语句

Vbscript用于单个返回语句的多个语句,vbscript,Vbscript,我正在开发一个VBScript,如下所示 Dim a Set a = New Class1 a("text").doSomething 'Has to execute doSomething in Class1 a("text").anotherSomething 'Has to execute doSoemthing in Class2 class Class1 Dim b Dim c public default Function init(str)

我正在开发一个VBScript,如下所示

Dim a
Set a = New Class1
a("text").doSomething 'Has to execute doSomething in Class1
a("text").anotherSomething 'Has to execute doSoemthing in Class2

class Class1
    Dim b
    Dim c
    public default Function init(str)
          Set b = New Class2
          Set c = New Class3
          'Some more operations to perform
          If **What is the condition can be?** Then
              Set init = c
          Else
              Set init = b
          End If
    End Function
End class

class Class2
    public Function doSomething()
        'Stuff to do something
    End Function
End class
class Class3
    public Function anotherSomething()
        'Stuff to do something
    End Function
End class
这里,对象“a”具有参数,并且该参数可以相同。 所以,我不能保留is参数“=”或“”

我不能把这些函数放在1类中


那么,什么条件可以决定呢。

看起来你需要利用委托人。基本上,您需要的内部对象是您想要访问OOP中父类中的方法的类型

以下是一个例子:

Class ScreenPoint
  '' Properties

  'Ancestor Point2D
  Private P2D
  'Point color
  Private Color
  '----------------------

  '' Methods
  'Constructor - called automatically
  Private Sub Class_Initialize()
    Set P2D = new Point2D
  End Sub
  '----------------------
  'Destructor - called automatically
  Private Sub Class_Terminate()
    Set P2D = Nothing
  End Sub
  '----------------------
  'A pair of methods to access private property X
  Property Get X
    X = P2D.X
  End Property

  Property Let X(ByVal in_X)
    P2D.X = in_X
  End Property
  '----------------------
  'A pair of methods to access private property Y
  Property Get Y
    Y = P2D.Y
  End Property

  Property Let Y(ByVal in_Y)
    P2D.Y = in_Y
  End Property
  '----------------------
End Class

如果您迷路了,请尝试在此处阅读源文章:

看起来您需要利用委托人。基本上,您需要的内部对象是您想要访问OOP中父类中的方法的类型

以下是一个例子:

Class ScreenPoint
  '' Properties

  'Ancestor Point2D
  Private P2D
  'Point color
  Private Color
  '----------------------

  '' Methods
  'Constructor - called automatically
  Private Sub Class_Initialize()
    Set P2D = new Point2D
  End Sub
  '----------------------
  'Destructor - called automatically
  Private Sub Class_Terminate()
    Set P2D = Nothing
  End Sub
  '----------------------
  'A pair of methods to access private property X
  Property Get X
    X = P2D.X
  End Property

  Property Let X(ByVal in_X)
    P2D.X = in_X
  End Property
  '----------------------
  'A pair of methods to access private property Y
  Property Get Y
    Y = P2D.Y
  End Property

  Property Let Y(ByVal in_Y)
    P2D.Y = in_Y
  End Property
  '----------------------
End Class

如果您迷路了,请尝试在此处阅读源文章:

多态性不是在VBScript中本机实现的,但可能有一些解决方法。多态性不是在VBScript中本机实现的,但可能有一些解决方法。