可能重复:
VB.NET := Operator
昨天我正在浏览Microsoft® Agent代码段,我看到:=在调用函数时使用。
我尝试在Google上搜索但我找不到与之相关的任何内容。
是的:=因为我们正在调用COM库的函数吗?代码:
Public Class Form1
Dim agent As AgentObjects.Agent
Dim merlin As AgentObjects.IAgentCtlCharacter
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
agent.Characters.Unload("merlin")
merlin = Nothing
agent = Nothing
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
agent = New AgentObjects.Agent
agent.Connected = True
agent.Characters.Load(CharacterID:="Merlin", LoadKey:="merlin.acs")
merlin = agent.Characters(CharacterID:="Merlin")
agent.PropertySheet.Visible = True
End Sub
Public Sub IntroMerlin()
Dim strName As String
With merlin
'Display character.
.Show()
'Make the character play an animation.
.Play(Animation:="Greet")
.Play(Animation:="Restpose")
.Speak(Text:="Hello!")
.Play(Animation:="Announce")
.Speak(Text:="I am Merlin.")
.Play(Animation:="Pleased")
.Speak(Text:="It is nice to meet you.")
End With
End Sub
End Class
感谢。
答案 0 :(得分:2)
那些是named parameters。如果函数具有带有默认值的长参数列表,则可能特别方便。您只需为要为其提供值的名称命名,您就不必处理位置要求。
答案 1 :(得分:2)
这是在VB / VBA / VB.NET中指定“命名参数”的方式 - 通过名称而不是位置提供参数。例如,请参阅this blog post。