Reputation: 6498
Possible Duplicate:
VB.NET := Operator
Yesterday I was browsing through Microsoft® Agent code snippets and I saw := used while calling a function.
I tried searching it in Google but I could not find anything related to it.
Is := used because we are calling a function of COM Library ?
Code :
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
Thanks.
Upvotes: 0
Views: 257
Reputation: 169143
This is how you specify "named arguments" in VB/VBA/VB.NET -- providing arguments by their name instead of their position. See, for example, this blog post.
Upvotes: 2
Reputation: 29000
Those are named parameters. It can be especially handy if a function has a long list of parameters with defaults. You just name the ones you want to provide values for, and you don't have to deal with positional requirements.
Upvotes: 2