|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
array dimensions and size errorI am seeking your help on a code taking from the internet that i would like to run on my pc(for learning reasons), unfortunately it is generating some errors that i can not understand on how to fix. It is a tictactoe game, i ll be pasting the code and stating the errors and where do they come from in order for anyone willing to help, to be able to assist me '------------------------------------------------------- Private Sub GamePlay(ByRef xo_Move As Integer) Dim x As Integer Dim y As Integer Dim iWin As Integer If lblPlayGround(xo_Move).Text = "" Then ' Update move counter iMove = iMove + 1 x = Int(xo_Move / 3) + 1 y = (xo_Move Mod 3) + 1 ' Update one of the arrays and check for a winner only in ' that array If sPlaySign = "O" Then iOPos(x, y) = 1 iWin = CheckWin(iOPos)<<<<<<<<<< Else iXPos(x, y) = 1 iWin = CheckWin(iXPos)<<<<<<<<<< End If lblPlayGround(xo_Move).Text = sPlaySign '----------------------------------------------------- <<< is where the error comes from this is how they are defined Dim iXPos(2, 2) As Integer Dim iOPos(2, 2) As Integer the error generated is "Value of type '2-dimensional array of Integer' cannot be converted to '1-dimensional array of Integer' because the array types have different numbers of dimensions." '------------------------------------------------------ the other error comes from the following code Function CheckWin(ByRef iPos() As Integer) As Integer Dim iScore As Integer Dim i As Integer Dim j As Integer CheckWin = -1 For i = 0 To 2 iScore = 0 CheckWin = CheckWin + 1 For j = 0 To 2 iScore = iScore + iPos(i, j)<<<<<<<<<<<<<< Next j If iScore = 2 Then Exit Function End If Next i where <<<< says : Number of indices exceeds the number of dimensions of the indexed array. there are many other same errors but once i understood where these two are coming from i think i ll be able to proceed myself. The application was written in VB6 and i am using . net 2003 it was converted automatically by the program to 2003. Thank you in advance for every useful hint or correction Try using this
Function CheckWin(ByRef iPos() As Variant) As Integer Perhaps this will help also... Ref: http://www.devx.com/tips/Tip/21273 -- Show quoteHide quoteRandem Systems Your Installation Specialist The Top Inno Setup Script Generator http://www.randem.com/innoscript.html Disk Read Error Press Ctl+Alt+Del to Restart http://www.randem.com/discus/messages/9402/9406.html?1236319938 "Totti" <saliba.toufic.geo***@gmail.com> wrote in message news:ff170902-48f7-4ed3-a4aa-e97e22769c8b@24g2000yqm.googlegroups.com... > Hi everyone, > I am seeking your help on a code taking from the internet that i would > like to run on my pc(for learning reasons), unfortunately it is > generating some errors that i can not understand on how to fix. > It is a tictactoe game, i ll be pasting the code and stating the > errors and where do they come from in order for anyone willing to > help, to be able to assist me > '------------------------------------------------------- > Private Sub GamePlay(ByRef xo_Move As Integer) > Dim x As Integer > Dim y As Integer > Dim iWin As Integer > > If lblPlayGround(xo_Move).Text = "" Then > ' Update move counter > iMove = iMove + 1 > x = Int(xo_Move / 3) + 1 > y = (xo_Move Mod 3) + 1 > ' Update one of the arrays and check for a winner only in > ' that array > If sPlaySign = "O" Then > iOPos(x, y) = 1 > iWin = CheckWin(iOPos)<<<<<<<<<< > Else > iXPos(x, y) = 1 > iWin = CheckWin(iXPos)<<<<<<<<<< > End If > lblPlayGround(xo_Move).Text = sPlaySign > '----------------------------------------------------- > <<< is where the error comes from > this is how they are defined > Dim iXPos(2, 2) As Integer > Dim iOPos(2, 2) As Integer > the error generated is "Value of type '2-dimensional array of Integer' > cannot be converted to '1-dimensional array of Integer' because the > array types have different numbers of dimensions." > '------------------------------------------------------ > the other error comes from the following code > Function CheckWin(ByRef iPos() As Integer) As Integer > Dim iScore As Integer > Dim i As Integer > Dim j As Integer > > CheckWin = -1 > For i = 0 To 2 > iScore = 0 > CheckWin = CheckWin + 1 > For j = 0 To 2 > iScore = iScore + iPos(i, j)<<<<<<<<<<<<<< > Next j > If iScore = 2 Then > Exit Function > End If > Next i > where <<<< says : Number of indices exceeds the number of dimensions > of the indexed array. > there are many other same errors but once i understood where these > two are coming from i think i ll be able to proceed myself. The > application was written in VB6 and i am using . net 2003 it was > converted automatically by the program to 2003. > Thank you in advance for every useful hint or correction > > > "Totti" <saliba.toufic.geo***@gmail.com> wrote in message This is a classic VB newsgroup (VB6 and previous versions). VB6 is in fact news:ff170902-48f7-4ed3-a4aa-e97e22769c8b@24g2000yqm.googlegroups.com... > I am seeking your help on a code taking from the > internet . . . The application was written in VB6 and > i am using . net 2003 it was converted automatically > by the program to 2003. the last and final version of Visual Basic. The product you are using is VB.Net, which is something completely different and which was inappropriately peppered with VB sounding constructs and dishonestly given the name VB or Visual Basic by the grinning Micro$oft sales gypsies in an attempt to give their new and completely different product a ride on the back of VB6 in order to increase sales. VB6 code does not work in VB.Net and VB.Net code does not work in VB6. Furthermore, as you have discovered, the Micro$oft utility which purports to be capable of converting VB6 code into VB.Net code does not actually work! Micro$oft were lying to you when then pretended that their conversion utility worked, just as they were lying to you when they put the name VB on their new dotnet product. Fortunately the Micro$oft technical people are not nearly as dishonest as their sales people and so they have created a new and completely different newsgroup for their new and completely different product. If you want to know how to rewrite your VB6 code so that it works in VB.Net then that's the place to go. You'll find it at the following place, which I have added to the newsgroups on the headers of this response so that they will know you are coming ;-) microsoft.public.dotnet.languages.vb Mike "Totti" <saliba.toufic.geo***@gmail.com> wrote in message This is a classic VB newsgroup (VB6 and previous versions). VB6 is in fact news:ff170902-48f7-4ed3-a4aa-e97e22769c8b@24g2000yqm.googlegroups.com... the last and final version of Visual Basic. The product you are using is VB.Net, which is something completely different and which was inappropriately peppered with VB sounding constructs and dishonestly given the name VB or Visual Basic by the grinning Micro$oft sales gypsies in an attempt to give their new and completely different product a ride on the back of VB6 in order to increase sales. VB6 code does not work in VB.Net and VB.Net code does not work in VB6. Furthermore, as you have discovered, the Micro$oft utility which purports to be capable of converting VB6 code into VB.Net code does not actually work! Micro$oft were lying to you when then pretended that their conversion utility worked, just as they were lying to you when they put the name VB on their new dotnet product. Fortunately the Micro$oft technical people are not nearly as dishonest as their sales people and so they have created a new and completely different newsgroup for their new and completely different product. If you want to know how to rewrite your VB6 code so that it works in VB.Net then that's the place to go. You'll find it at the following place, which I have added to the newsgroups on the headers of this response so that they will know you are coming ;-) microsoft.public.dotnet.languages.vb Mike Hi Totti,
The fix for this is simple, just change the defintion to: Function CheckWin(ByRef iPos(,) As Integer) As Integer I would also recommend changing those to ByVal other than ByRef. If you've got more questions about VB .NET, please ask in the dotnet dedicated newsgroups: microsoft.public.dotnet.languages.vb, Show quoteHide quote "Totti" <saliba.toufic.geo***@gmail.com> wrote in message news:ff170902-48f7-4ed3-a4aa-e97e22769c8b@24g2000yqm.googlegroups.com... > Hi everyone, > I am seeking your help on a code taking from the internet that i would > like to run on my pc(for learning reasons), unfortunately it is > generating some errors that i can not understand on how to fix. > It is a tictactoe game, i ll be pasting the code and stating the > errors and where do they come from in order for anyone willing to > help, to be able to assist me > '------------------------------------------------------- > Private Sub GamePlay(ByRef xo_Move As Integer) > Dim x As Integer > Dim y As Integer > Dim iWin As Integer > > If lblPlayGround(xo_Move).Text = "" Then > ' Update move counter > iMove = iMove + 1 > x = Int(xo_Move / 3) + 1 > y = (xo_Move Mod 3) + 1 > ' Update one of the arrays and check for a winner only in > ' that array > If sPlaySign = "O" Then > iOPos(x, y) = 1 > iWin = CheckWin(iOPos)<<<<<<<<<< > Else > iXPos(x, y) = 1 > iWin = CheckWin(iXPos)<<<<<<<<<< > End If > lblPlayGround(xo_Move).Text = sPlaySign > '----------------------------------------------------- > <<< is where the error comes from > this is how they are defined > Dim iXPos(2, 2) As Integer > Dim iOPos(2, 2) As Integer > the error generated is "Value of type '2-dimensional array of Integer' > cannot be converted to '1-dimensional array of Integer' because the > array types have different numbers of dimensions." > '------------------------------------------------------ > the other error comes from the following code > Function CheckWin(ByRef iPos() As Integer) As Integer > Dim iScore As Integer > Dim i As Integer > Dim j As Integer > > CheckWin = -1 > For i = 0 To 2 > iScore = 0 > CheckWin = CheckWin + 1 > For j = 0 To 2 > iScore = iScore + iPos(i, j)<<<<<<<<<<<<<< > Next j > If iScore = 2 Then > Exit Function > End If > Next i > where <<<< says : Number of indices exceeds the number of dimensions > of the indexed array. > there are many other same errors but once i understood where these > two are coming from i think i ll be able to proceed myself. The > application was written in VB6 and i am using . net 2003 it was > converted automatically by the program to 2003. > Thank you in advance for every useful hint or correction > > >
VB Express and VB files
Is my VB6 app form open? Vista 64 and Visual Studio 6 Keeping 2 listboxes in sync - VB6 ListBox - Limit Selection Rectangle Width In-Process and Out-of-Process Best method to have 2 checkboxes for 1 item Command Line Exporting a function from VB.net DLL CheckedListBox Selecting Items |
|||||||||||||||||||||||