|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
C# to VB Conversion - 800 lines got - 2 lines beyond meam trying to convert c# app to VB so change alter parts of it. But am getting confused by a couple of bits... at least ;-) a) private point[] path1(point p1, point p2) { int minX = Math.Min(p1.X, p2.X); int maxX = Math.Max(p1.X, p2.X); for (i = minX + 1; i < maxX && isCellEmpty(p1.Y, i); i++) ; return i == maxX ? new Point[] { p1, p2 } : null; } isCell Empty returns boolean can convert most but for line confusing me. is loop all that line or is return part of loop if only looping that line - it does nothing. If return part of the loop - can you return more than once... b) public event EventHandler OnGameWon { add { gameWon += value; } remove { gameWon -= value; } } What the heck? add? remove? new c# 2005 I think - msdn help just confuses me. Any assistance greatly appreciated >can convert most but for line confusing me. is loop all that line or is The loop has an empty body, so it's just that one line. It keeps>return part of loop >if only looping that line - it does nothing. incrementing i until i >= maxX or isCellEmpty returns false. >b) No C# has had this syntax since day one. VB got a similar feature> > public event EventHandler OnGameWon { > add { > gameWon += value; > } > remove { > gameWon -= value; > } > } > >What the heck? add? remove? new c# 2005 I think - msdn help just confuses >me. (custom events) in the 2005 release. But unless you have a good reason for using it you can simply go with Public Event OnGameWon As EventHandler Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. Thank you Mattias
Will try those as soon as Now only one class to go - then can start making upgrades/personalizations in a syntax I understand. ;-) Well better anyway. Kaypee Show quoteHide quote "Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message news:%23hVdCRHhGHA.3924@TK2MSFTNGP03.phx.gbl... > >can convert most but for line confusing me. is loop all that line or is >>return part of loop >>if only looping that line - it does nothing. > > The loop has an empty body, so it's just that one line. It keeps > incrementing i until i >= maxX or isCellEmpty returns false. > > >>b) >> >> public event EventHandler OnGameWon { >> add { >> gameWon += value; >> } >> remove { >> gameWon -= value; >> } >> } >> >>What the heck? add? remove? new c# 2005 I think - msdn help just >>confuses >>me. > > No C# has had this syntax since day one. VB got a similar feature > (custom events) in the 2005 release. But unless you have a good reason > for using it you can simply go with > > Public Event OnGameWon As EventHandler > > > Mattias > > -- > Mattias Sjögren [C# MVP] mattias @ mvps.org > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > Please reply only to the newsgroup. Here's the actual VB equivalent (via our Instant VB C# to VB converter) -
note that VB (2005) requires the RaiseEvent section. Private Function path1(ByVal p1 As point, ByVal p2 As point) As point() Dim minX As Integer = Math.Min(p1.X, p2.X) Dim maxX As Integer = Math.Max(p1.X, p2.X) i = minX + 1 Do While i < maxX AndAlso isCellEmpty(p1.Y, i) i += 1 Loop If i = maxX Then Return New Point() { p1, p2 } Else Return Nothing End If End Function Public Custom Event OnGameWon As EventHandler AddHandler(ByVal value As EventHandler) AddHandler gameWon, value End AddHandler RemoveHandler(ByVal value As EventHandler) RemoveHandler gameWon, value End RemoveHandler RaiseEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) End RaiseEvent End Event -- Show quoteHide quoteDavid Anton www.tangiblesoftwaresolutions.com Instant C#: VB to C# converter Instant VB: C# to VB converter Instant C++: C# to C++ converter & VB to C++ converter Instant J#: VB to J# converter "Kaypee" wrote: > Howdy all > > am trying to convert c# app to VB so change alter parts of it. > > But am getting confused by a couple of bits... at least ;-) > > a) > private point[] path1(point p1, point p2) { > int minX = Math.Min(p1.X, p2.X); > int maxX = Math.Max(p1.X, p2.X); > for (i = minX + 1; i < maxX && isCellEmpty(p1.Y, i); i++) ; > return i == maxX ? new Point[] { p1, p2 } : null; > } > > isCell Empty returns boolean > > can convert most but for line confusing me. is loop all that line or is > return part of loop > if only looping that line - it does nothing. If return part of the loop - > can you return more than once... > > b) > > public event EventHandler OnGameWon { > add { > gameWon += value; > } > remove { > gameWon -= value; > } > } > > What the heck? add? remove? new c# 2005 I think - msdn help just confuses > me. > > > > Any assistance greatly appreciated > > >
Why choose SQL Express over Access?
Anyway To Compress PDF from .NET? Visual Basic 6.0 X Visual Basic 2005 Express AxWebBrowser problems in VS2005 Seeking report component.... Saving changes to a database Setting the correct tabindex VB.NET & SQL Server Connection Example A couple of newbie questions How to test internet connection in VB.NET? |
|||||||||||||||||||||||