What is the use of := in this program?
本问题已经有最佳答案,请猛点这里访问。
Possible Duplicate:
VB.NET := Operator
昨天我在浏览微软?代理代码片段,我看到:=在调用函数时使用。
我试着在谷歌上搜索它,但找不到任何相关的信息。
是否使用:=因为我们正在调用COM库的函数?
代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 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 |
谢谢。
这就是在vb/vba/vb.net中指定"命名参数"的方法——通过参数的名称而不是位置来提供参数。例如,请参阅此博客文章。
这些是命名参数。如果一个函数有一长串带有默认值的参数,那么它就特别方便。你只需说出你想要为其提供值的那些,而不需要处理位置需求。