473,395 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# to VB Conversion - 800 lines got - 2 lines beyond me

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
May 31 '06 #1
3 1789
>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.
May 31 '06 #2
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

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@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.

May 31 '06 #3
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

--
David 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

May 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: kalio80 | last post by:
Hi everyone I am trying to create a file that converts text files from unix to windows and windows to unix I understand the general concept of it as unix uses line feed LF Windows uses CRLF...
5
by: john | last post by:
Here is the short story of what i'm trying to do. I have a 4 sided case labeling printer setting out on one of our production lines. Now then i have a vb.net application that sends data to this...
26
by: David W. Fenton | last post by:
A client is panicking about their large Access application, which has been running smoothly with 100s of thousands of records for quite some time. They have a big project in the next year that will...
8
by: Perception | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
9
by: Ben Midgley | last post by:
Please have a look at the code below My problem is the error message "Nonportable pointer conversion", so far as I can tell there is no pointer conversion occuring here so I am assuming it is...
8
by: Duncan Winn | last post by:
I am new to VC++7. I am using a method GetPrivateProfileString that requires an LPTSTR. I have defined this as a: char * data_name; I am then trying to convert this to an LPOLESTR and I...
31
by: Martin Jørgensen | last post by:
Hi, I've had a introductory C++ course in the spring and haven't programmed in C++ for a couple of months now (but I have been programmed in C since january). So I decided to do my conversion...
15
by: bcpkh | last post by:
Hello All I have a simple task that is driving me crazy. A string representing a duration in the following format is passed to my application, a function is dedicated to convert this duration to...
6
by: Lasse Reichstein Nielsen | last post by:
Max <adsl@tiscali.itwrites: Not really. It shows that a particularly naïve implementation of a conversion from XML to JSON doesn't work well. What if the conversion of <e> some
3
by: prakashwadhwani | last post by:
I have just been asked to port an Access 97 app from an old Pentium 3 to a new Pentium Core-2-Duo PC. On the new PC, Office 2003 is installed. On opening the database, Access provided me with an...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.