0

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.

Community
  • 1
  • 1
Searock
  • 6,278
  • 11
  • 62
  • 98
  • @Georg Fritzsche Yeah its a duplicate of VB.NET := Operator, I tried to search := operator in C# instead of := operator in Vb.net. That's so stupid of me. Even I have voted for closing this question. – Searock Nov 09 '10 at 06:17
  • Very honest of you! I'll vote to close also. – MarkJ Nov 09 '10 at 12:00

2 Answers2

2

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.

Mud
  • 28,277
  • 11
  • 59
  • 92
2

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.

cdhowie
  • 158,093
  • 24
  • 286
  • 300