PLA Forums
Other Stuff That Has Little To Do With PLA => Techinical Shit => Technical Support => Topic started by: BrianOlsen on June 16, 2007, 09:59:46 PM
-
Ok, Rev, here's the new thread I'm starting. I'm making a game in Visual basic for a class, it is just a tic tac toe game but it's going to be for the Windows 32bit platform and it'll be a desktop application and not a DOS app. My teacher has helped me with a few things and I did get some information online. I'm getting quite of few debugging errors, so bare with me.
Here's what I have:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3825
ClientLeft = 5370
ClientTop = 2040
ClientWidth = 4890
LinkTopic = "Form1"
ScaleHeight = 3825
ScaleWidth = 4890
Begin VB.OptionButton Option2
Caption = "Advanced"
Height = 255
Left = 2520
TabIndex = 23
Top = 3480
Width = 1095
End
Begin VB.OptionButton Option1
Caption = "Beginner"
Height = 255
Left = 960
TabIndex = 22
Top = 3480
Value = -1 'True
Width = 975
End
Begin VB.TextBox Text2
Alignment = 1 'Right Justify
BackColor = &H80000004&
Height = 285
Left = 4440
TabIndex = 16
Text = "0"
Top = 480
Width = 375
End
Begin VB.TextBox Text4
Alignment = 1 'Right Justify
BackColor = &H80000000&
Height = 285
Left = 4440
TabIndex = 15
Text = "0"
Top = 1200
Width = 375
End
Begin VB.TextBox Text3
Alignment = 1 'Right Justify
BackColor = &H80000000&
Height = 285
Left = 4440
TabIndex = 14
Text = "0"
Top = 840
Width = 375
End
Begin VB.TextBox Text5
Alignment = 1 'Right Justify
BackColor = &H80000000&
Height = 285
Left = 4440
TabIndex = 13
Text = "1"
Top = 1560
Width = 375
End
Begin VB.CommandButton Command2
Caption = "Reset all"
Height = 495
Left = 3480
TabIndex = 12
Top = 2040
Width = 1335
End
Begin VB.CommandButton Command3
Caption = "Exit"
Height = 615
Left = 3960
TabIndex = 11
Top = 2760
Width = 855
End
Begin VB.CommandButton Command1
Caption = "Play Again?"
Height = 495
Left = 360
TabIndex = 10
Top = 2760
Width = 1935
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 9
Left = 1920
TabIndex = 9
Top = 1920
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 8
Left = 1320
TabIndex = 8
Top = 1920
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 7
Left = 720
TabIndex = 7
Top = 1920
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 6
Left = 120
TabIndex = 6
Top = 1920
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 5
Left = 1320
TabIndex = 5
Top = 1320
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 4
Left = 720
TabIndex = 4
Top = 1320
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 3
Left = 120
TabIndex = 3
Top = 1320
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 2
Left = 1320
TabIndex = 2
Top = 720
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 1
Left = 720
TabIndex = 1
Top = 720
Width = 615
End
Begin VB.TextBox Text1
BackColor = &H0000FF00&
Height = 615
Index = 0
Left = 120
TabIndex = 0
Top = 720
Width = 615
End
Begin VB.Label Label5
Caption = "Tic Tac Toe"
BeginProperty Font
Name = "MS Sans Serif"
Size = 18
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000D&
Height = 375
Left = 960
TabIndex = 21
Top = 0
Width = 2295
End
Begin VB.Label Label3
Caption = "Games Tied"
Height = 255
Left = 3480
TabIndex = 20
Top = 1200
Width = 855
End
Begin VB.Label Label2
Caption = "Wins by O"
Height = 255
Left = 3600
TabIndex = 19
Top = 840
Width = 735
End
Begin VB.Label Label1
Caption = "Wins by X"
Height = 255
Left = 3600
TabIndex = 18
Top = 480
Width = 735
End
Begin VB.Label Label4
Caption = "Game #"
Height = 255
Left = 3720
TabIndex = 17
Top = 1560
Width = 615
End
End
I have everything labeled and I have a nice GUI already made, but lets start with the DIMs and attributes............here;
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim owin As Integer
Dim xwin As Integer
Dim gnum As Integer
Dim tiedg As Integer
Dim moves As Integer
Dim xoro As Integer
Dim x As Integer
Dim comp As Integer
Dim kswitch As Integer
Dim diff As Integer
Dim s As Integer
Dim done As Integer
Dim square As Integer
Dim y As Integer
Dim yn As Integer
Dim dblscore As Integer
I'm getting a bunch of syntax errors with these beginning lines....what do you think?
-
Oh my god, you have everything as an Integer. I'm trying to understand what you have DIM'ed in relation to that game. I was somewhat able to figure it out. I mean, "x" and "y", and "tieg" are the easy ones among others. Since you're not showing all of your code - I'm going to guess as if I was writing it. Lets try this:
Find:
Dim xoro As Integer
Change To:
Dim xoro As String
Find:
Dim x As Integer
Change To:
Dim x As String
Find:
Dim s As Integer
Change To:
Dim s As Boolean
Find:
Dim y As Integer
Change To:
Dim y As Boolean
Find:
Dim yn As Integer
Change To:
Dim yn As String
Tell me what happens.
-
Nobody uses VB classic anymore, it's all .NET now!
-
i use BASIC on my commodore :) I even found a cool emulator to use BASIC on my NintendoDS!
-
QBASIC was the first (and only) programming language I ever learned (aside from HTML, but that doesn't count).
-
Ok,
Here's the next section that I did, again, syntax errors. However, I used your above changes and the errors aren't on those lines anymore because I changed throughout my code. I think its the IF THEN statements that the debugger isn't liking.
Section 1:
Private Function cdone()
done = rowcheck()
If (done <> -1) Then
dblscore = dblscore + 1
Call printmsg("row", done)
End If
done = colcheck()
If (done <> -1) Then
dblscore = dblscore + 1
Call printmsg("col", done)
End If
done = diagcheck()
If (done <> -1) Then
dblscore = dblscore + 1
Call printmsg("diag", done)
End If
End Function
Section 2:
Private Function gquit()
Dim ii As Integer
For ii = 0 To 9
Text1(ii).Enabled = False
Next ii
Call win
End Function
Private Function movesf()
If (moves = 10) Then
tiedg = tiedg + 1
MsgBox "The game is a tie."
Text4.Text = Str(tiedg)
Call gquit
End If
End Function
Section 3:
Private Function win()
moves = 0
If (dblscore = 1) Then
If (xoro = "X") Then
xwin = xwin + 1
Text2.Text = Str(xwin)
If
owin = owin + 1 Then
Text3.Text = Str(owin)
End If
If (xoro = "X") Then
xwin = xwin
Text2.Text = Str(xwin)
If
owin = owin
Text3.Text = Str(owin)
End If
End If
kswitch = 1
End Function
-
Section 1 and 2 look pretty good to me. However, Section 3 would be more feasible like this:
Private Function win()
moves = 0
If (dblscore = 1) Then
If (xoro = "X") Then
xwin = xwin + 1
Text2.Text = Str(xwin)
Else
owin = owin + 1
Text3.Text = Str(owin)
End If
Else
If (xoro = "X") Then
xwin = xwin
Text2.Text = Str(xwin)
Else
owin = owin
Text3.Text = Str(owin)
End If
End If
kswitch = 1
End Function
I've added ELSE statements instead of the IF THEN only flow.