\r\n\r\n
Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Why did they do this ?


\r\n \r\n
 
 
Thread Tools Display Modes

\r\n\r\n\r\n
I have been going through a tutorial and came across this code:
\r\n
\r\n
Code:
\r\n
Private Delegate Sub DisplayTextCallback(ByVal Text As String)\r\nPrivate Sub CallDisplayTextCallback(ByVal Text As String)\r\n        Dim cb As New DisplayTextCallback(AddressOf DisplayText)\r\n        Dim args() As Object = {Text}  \r\n        Me.Invoke(cb, args)\r\nEnd Sub
\r\n
I replaced the last 2 lines of the sub with:
\r\n
Code:
\r\n
Me.Invoke(cb, Text)
\r\n
and it works perfectly.
\r\n
\r\nWhy did they create an object array?
\r\nIs it okay to use the "Text" keyword as a variable?
\r\n
\r\nI would greatly appreciate any explanations.
\r\n \r\n\r\n
\r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n \r\n \r\n \r\n \r\n Reply With Quote\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n
\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n\r\n'; pd[1394354] = '\r\n\r\n \r\n\r\n
\r\n
\r\n
\r\n\r\n
\r\n \r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n
\r\n
\r\n  \r\n #2  \r\n \r\n \r\n \r\n \r\n \r\n
\r\n\r\n
\r\n \r\n Old\r\n \r\n 06-10-2012, 06:36 AM\r\n \r\n \r\n \r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
snarfblam\'s Avatar\r\n\r\n
\r\n \r\n snarfblam\r\n snarfblam is offline\r\n\r\n\r\n
Prev Previous Post   Next Post Next
  #1  
Old 06-10-2012, 01:16 AM
philman philman is offline
Freshman
 
Join Date: Mar 2011
Posts: 32
Default Why did they do this ?


I have been going through a tutorial and came across this code:
Code:
Private Delegate Sub DisplayTextCallback(ByVal Text As String)
Private Sub CallDisplayTextCallback(ByVal Text As String)
        Dim cb As New DisplayTextCallback(AddressOf DisplayText)
        Dim args() As Object = {Text}  
        Me.Invoke(cb, args)
End Sub
I replaced the last 2 lines of the sub with:
Code:
Me.Invoke(cb, Text)
and it works perfectly.

Why did they create an object array?
Is it okay to use the "Text" keyword as a variable?

I would greatly appreciate any explanations.
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->