|
-
Jun 10th, 2011, 02:59 PM
#1
Thread Starter
Lively Member
6.0 -> 2010
hi
i was used to be vb 6.0. but now im starting with vb 2010 because 6.0 is old 
but now i have a few problems with converting some things for my game that im making.
in 6.0 it was
modPlayer (module)
Code:
Public Player(1 To MAX_PLAYERS) as PlayerRec
Private Type PlayerRec
Name as string
Level as string
End Type
but this code gives in 2010 some errors; it says it should be structures right now?
Code:
Module modPlayerRec
Public Player(0 To 100) As PlayerRec
Structure PlayerRec
Public Name As String
End Structure
End Module
what should be the right code for vb 2010? this is not working what i have right now..
thanks in advanced!
-
Jun 10th, 2011, 03:04 PM
#2
Re: 6.0 -> 2010
try this:
vb Code:
Private Structure PlayerRec
Private Name as string
Private Level as string
End Structure
Public Player(MAX_PLAYERS - 1) as PlayerRec 'arrays are zero based in vb.net
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 10th, 2011, 03:05 PM
#3
Re: 6.0 -> 2010
Whether the upper bound of the array needs to be 100 is hard to say, that depends on what you had for MAX_PLAYERS, previously. However, you don't need the "0 to" part. All collections in .NET are 0 based, so explicitly stating that fact isn't necessary.
The Type you had before had two members, but the one you show in the second snippet has only one. What happened to the level?
As a general practice, it often isn't so good to use Public member variables. It takes a bit more typing, but if you make the member variables private, and expose them via properties, you get a few advantages....which you may not even care about. I sometimes use Public members for some classes, but only very rarely, and only when there is no chance that I will binding or searching them. Since you have an array, both of those are more likely.
Also, there might be a question whether to use a Structure or a Class, but as you have it, a Structure will work fine.
My usual boring signature: Nothing
 
-
Jun 10th, 2011, 03:05 PM
#4
Re: 6.0 -> 2010
I thought I might be taking too long.
My usual boring signature: Nothing
 
-
Jun 10th, 2011, 03:15 PM
#5
Thread Starter
Lively Member
Re: 6.0 -> 2010
Great I got it working! thanks!
Code:
Public Player(0 To 100) As PlayerRec
Public Structure PlayerRec
Public Name As String
Public Level As String
End Structure
-
Jun 10th, 2011, 05:59 PM
#6
Re: 6.0 -> 2010
You still don't need the (0 to 100). You only need the (100), because the "0 to" is automatic.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|