开发者

What is the use of := in this program? [duplicate]

This question already has answers here: Closed 12 years ago.

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:开发者_如何学JAVA="I am Merlin.")
            .Play(Animation:="Pleased")
            .Speak(Text:="It is nice to meet you.")
        End With
    End Sub
End Class

Thanks.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜