home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 1689
Discussions: 188,402, Posts: 2,243,609, Members: 232,632
Old April 19th, 2005, 08:10 PM   Digg it!   #1 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
3 X 3 Integer array VB

How do I add 3X3 array

1 2 1
2 1 1
2 1 1

if I wanted to add the first row together how could I do that? 1 + 2 + 2 ?

sum ={0,0} + {1,0} + {2,0}


I'm using Studio .Net with VB to write this.

redfox
__________________
For the Emperor, there were the Jedi. For the Evil Empire of Microsoft, there is a penguin.

redfoxstorm is offline   Reply With Quote
Old April 19th, 2005, 08:27 PM     #2 (permalink)
Ultimate Member
 
meese's Avatar
 
Join Date: Jun 2003
Location: NJ
Posts: 2,467
Do you mean row or column?

meese is offline   Reply With Quote
Old April 19th, 2005, 08:34 PM     #3 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
I actually I'm doing a tic tac toe game and I figured if i had the game check the rows and the columns it could figure out who wins. ......so both

redfoxstorm is offline   Reply With Quote
Old April 19th, 2005, 08:41 PM     #4 (permalink)
Ultimate Member
 
Join Date: Jan 2003
Location: MA / NH
Posts: 1,497
Send a message via AIM to Blazer06
Quote:
Originally Posted by redfoxstorm
I actually I'm doing a tic tac toe game and I figured if i had the game check the rows and the columns it could figure out who wins. ......so both

Well as far as a tic tac toe game, what if they make a diagonal path. You’re gonna be setting yourself up for a lot of needless coding if you do it that way.

Instead of using a multi-dimensional array, why don’t you use three simple arrays?


-Blaze
Blazer06 is offline   Reply With Quote
Old April 19th, 2005, 08:44 PM     #5 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
true...
redfoxstorm is offline   Reply With Quote
Old April 19th, 2005, 10:14 PM     #6 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
the assignment calls for me to make a class that has a private data of 3 by 3 integer array? The constructor should initialized the empty board to all zeros.


Doesn't this work for the 3 by 3 Array?
Code:
Public Class CTicTacToe
    Inherits Object

    Private grid As Array

    Public Sub New()
        Dim grid1 As Integer(,)
        grid1 = New Integer(,) {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
    End Sub

    Public Sub grid1(,){{byVal label1.text As Integer, ByVal label2.text As integer, ByVal label3.text As integer},{{ByVal label4.text As Integer, ByVal Label5.text As Integer, ByVal Label6.text As Integer}, {ByVal label7.text As Integer, ByVal Label8.text As Integer, ByVal Label9.text As Integer}}
redfoxstorm is offline   Reply With Quote
Old April 19th, 2005, 10:15 PM     #7 (permalink)
I am a banana!
 
originel's Avatar
 
Join Date: Jun 2002
Location: Texas Tech
Posts: 3,921
Send a message via AIM to originel
I'd still do a multi-dimensional array. IMO it actually would be easier than three simple arrays because you can do this to sum your diagonal rows:

Code:
for i = 0 to 2
     mySum1 = myArray(i,i)
     mySum2 = myArray(i,2-i)
next
to add them together, you would do this:
Code:
mySum = myArray(row,column) + myArray(row,column) + myArray(row,column)
You can also throw things into loops which might make things easier.

EDIT: Ewwwww, you guys are doing classes in VB? That's like hot rodding a chevy nova!
originel is offline   Reply With Quote
Old April 19th, 2005, 11:17 PM     #8 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
Quote:
Ewwwww, you guys are doing classes in VB? That's like hot rodding a chevy nova!
Is that like awesome or bad?

Red
redfoxstorm is offline   Reply With Quote
Old April 20th, 2005, 12:52 AM     #9 (permalink)
Ultimate Member
 
Join Date: Dec 2004
Posts: 1,558
Quote:
Is that like awesome or bad?
Superfluous really. There isn't any real, legitimate reason to be using classes in VB, especially at the level it's being used at. It's pointless, like "hot rodding a chevy nova"
__________________
"Be quiet, Brain, or I'll stab you with a Q-tip"
-Homer Simpson
large_nostril is offline   Reply With Quote
Old April 20th, 2005, 07:17 PM     #10 (permalink)
Member
 
redfoxstorm's Avatar
 
Join Date: Feb 2005
Posts: 386
Hey, since I don't have to have an array in the program...this is as far as I've gotten with my tictactoe program

I just need to make a way to check my results after each click?

I think this is where the class comes in at.


Code:
Public Class Form1
    Dim User1 As Integer
    Dim User2 As Integer
    Dim Usersumx As Integer
    Dim Usersumo As Integer




    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        User2 = 0
        User1 = 1
        Label10.Text = ""
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        User1 = 0
        User2 = 2

    End Sub


    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        If user1 = 1 Then
            Label1.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label1.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

  
   
    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
        If User1 = 1 Then
            Label2.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label2.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub


    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
        If User1 = 1 Then
            Label3.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label3.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
        If User1 = 1 Then
            Label4.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label4.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
        If User1 = 1 Then
            Label5.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label5.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

    Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
        If User1 = 1 Then
            Label6.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label6.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

    Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click
        If User1 = 1 Then
            Label7.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label7.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

    Private Sub Label8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label8.Click
        If User1 = 1 Then
            Label8.Text = " X "
            Usersumx = Usersumx + 1
        End If
        If User2 = 2 Then
            Label8.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

    Private Sub Label9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label9.Click
        If User1 = 1 Then
            Label9.Text = " X "
            Usersumx = Usersumx + 1

        End If


        If User2 = 2 Then
            Label9.Text = " 0 "
            Usersumo = Usersumo + 1
        End If
    End Sub

   
End Class
redfoxstorm is offline   Reply With Quote
Reply


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

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not find array galehickey Technical Support 10 July 10th, 2004 11:42 PM
more integer spaces korgul Webmastering and Programming 15 July 1st, 2003 02:04 AM
integer performance dmanlyr Processors, Memory, and Overclocking 2 December 1st, 2002 10:20 AM
run-time error R6003 -integer divide by 0urface Scan Richard Cranium Technical Support 7 October 29th, 2002 07:52 PM
integer divide by 0 error MDS Applications and Operating Systems 4 May 25th, 2002 05:15 AM

Most Active Discussions
Is It Just Me? (2906)
3-days in and no threads about Gaza (161)
Misery Loves Company... (2144)
New Build ( Finally ) (7)
CPU wont boot (7)
Building a gaming computer advice (5)
I think I just killed my computer w.. (24)
RCA 52Inch HDTV wont turn on (5)
Folderchat Weekday thread (444)
Recent Discussions
Futronix has water features? (0)
Laptop proccesor to desktop mob.. (2)
Please help! multiple problems! (4)
RCA 52Inch HDTV wont turn on (5)
New Build ( Finally ) (7)
Common Spyware Solutions (97)
How do you move a hard-drive to.. (4)
What is the best external enclo.. (0)
Partition Magic 7.0 (Unallocate.. (17)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 04:36 AM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28