Letters to Images Problem
I need some help in figuring out how to retrieve the letter for each block.
Code:
Sub Main()
Randomize
X = Int((19 * Rnd) + 1) 'you have 19 lines in the text file
' edit the following so it is the path to your file
Open (App.Path = "\bbee\text\puzzleletters.txt") & Input(Str(Y))
For Y = 1 To X 'this will get the x'th line
Input #1, NewPuzzle
Next Y
Close #1
NewLetter = 1
RoundOne.Show
End Sub
The bolded line is where I am having problems with retrieving the letter for each block. User Caskbill did create the code on my behalf, but originally it failed. I edited his code (shown in bold), and I am still experiencing problems. Where did we go wrong?
Also, I did a test run, and it detected an error on the line that reads "VERSION 5#." What was wrong there?
Here is the code from the forms file:
Code:
VERSION 5#
Begin VB.Form RoundOne
BackColor = &H8000000A
Caption = "Form1"
ClientHeight = 9270
ClientLeft = 60
ClientTop = 450
ClientWidth = 13515
DrawStyle = 5 'Transparent
FillColor = &H8000000B
LinkTopic = "Form1"
ScaleHeight = 9270
ScaleWidth = 13515
StartUpPosition = 3 'Windows Default
Begin Project1.UserControl1 UC
Height = 1095
Index = 1
Left = 1560
TabIndex = 31
Top = 960
Width = 1575
_ExtentX = 2778
_ExtentY = 1931
Picture = "RoundOne1.frx":0000
MaskColor = 16711680
MaskPicture = "RoundOne1.frx":56BA
ScaleHeight = 1095
ScaleWidth = 1575
End
Begin VB.PictureBox Picture1
BackColor = &H80FF80
BorderStyle = 0 'None
Height = 6735
Index = 1
Left = 0
ScaleHeight = 6735
ScaleWidth = 9495
TabIndex = 29
Top = 0
Width = 9495
Begin VB.Timer Timer2
Left = 720
Top = 120
End
Begin VB.Timer Timer1
Left = 0
Top = 0
End
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 495
Left = 9840
TabIndex = 23
Top = 6600
Width = 615
End
Begin VB.CommandButton Command2
Caption = "2"
Height = 495
Left = 9840
TabIndex = 22
Top = 7200
Width = 615
End
Begin VB.CommandButton Command3
Caption = "3"
Height = 495
Left = 9840
TabIndex = 21
Top = 7800
Width = 615
End
Begin VB.CommandButton Command4
Caption = "4"
Height = 495
Left = 9840
TabIndex = 20
Top = 8400
Width = 615
End
Begin VB.CommandButton Command5
Caption = "5"
Height = 495
Left = 10560
TabIndex = 19
Top = 6840
Width = 615
End
Begin VB.CommandButton Command6
Caption = "6"
Height = 495
Left = 10560
TabIndex = 18
Top = 7440
Width = 615
End
Begin VB.CommandButton Command7
Caption = "7"
Height = 495
Left = 10560
TabIndex = 17
Top = 8040
Width = 615
End
Begin VB.CommandButton Command8
Caption = "8"
Height = 495
Left = 10560
TabIndex = 16
Top = 8640
Width = 615
End
Begin VB.CommandButton Command9
Caption = "9"
Height = 495
Left = 11280
TabIndex = 15
Top = 6600
Width = 615
End
Begin VB.CommandButton Command10
Caption = "10"
Height = 495
Left = 11280
TabIndex = 14
Top = 7200
Width = 615
End
Begin VB.CommandButton Command11
Caption = "11"
Height = 495
Left = 11280
TabIndex = 13
Top = 7800
Width = 615
End
Begin VB.CommandButton Command12
Caption = "12"
Height = 495
Left = 11280
TabIndex = 12
Top = 8400
Width = 615
End
Begin VB.CommandButton Command13
Caption = "13"
Height = 495
Left = 12000
TabIndex = 11
Top = 6840
Width = 615
End
Begin VB.CommandButton Command14
Caption = "14"
Height = 495
Left = 12000
TabIndex = 10
Top = 7440
Width = 615
End
Begin VB.CommandButton Command15
Caption = "15"
Height = 495
Left = 12000
TabIndex = 9
Top = 8040
Width = 615
End
Begin VB.CommandButton Command16
Caption = "16"
Height = 495
Left = 12000
TabIndex = 8
Top = 8640
Width = 615
End
Begin VB.CommandButton Command17
Caption = "17"
Height = 495
Left = 12720
TabIndex = 7
Top = 6600
Width = 615
End
Begin VB.CommandButton Command18
Caption = "18"
Height = 495
Left = 12720
TabIndex = 6
Top = 7200
Width = 615
End
Begin VB.CommandButton Command19
Caption = "19"
Height = 495
Left = 12720
TabIndex = 5
Top = 7800
Width = 615
End
Begin VB.CommandButton Command20
Caption = "20"
Height = 495
Left = 12720
TabIndex = 4
Top = 8400
Width = 615
End
Begin VB.PictureBox RedScore
BorderStyle = 0 'None
Height = 615
Left = 9600
ScaleHeight = 615
ScaleWidth = 1815
TabIndex = 3
Top = 3720
Width = 1815
End
Begin VB.PictureBox WhiteScore
BorderStyle = 0 'None
Height = 615
Left = 11520
ScaleHeight = 615
ScaleWidth = 1815
TabIndex = 2
Top = 3720
Width = 1815
End
Begin VB.TextBox AnswerBar
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3720
TabIndex = 1
Text = "Text1"
Top = 8640
Width = 5775
End
Begin VB.PictureBox Picture60
BorderStyle = 0 'None
Height = 2655
Left = 9600
Picture = "RoundOne1.frx": AD74
ScaleHeight = 2655
ScaleWidth = 3735
TabIndex = 0
Top = 240
Width = 3735
End
Begin VB.Label Label3
Alignment = 2 'Center
BackColor = &HFFFFFF
Caption = "White Player Press ""P"""
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 9600
TabIndex = 30
Top = 4800
Width = 3735
End
Begin VB.Label QuestionBox
Alignment = 2 'Center
BackColor = &H800000
Caption = "Label1"
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80FFFF
Height = 1455
Left = 0
TabIndex = 28
Top = 6960
Width = 9495
End
Begin VB.Label RedPlayerLabel
Alignment = 2 'Center
BackColor = &HFF&
Caption = "Label1"
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 9600
TabIndex = 27
Top = 3120
Width = 1815
End
Begin VB.Label WhitePlayerLabel
Alignment = 2 'Center
BackColor = &HFFFFFF
Caption = "Label2"
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 11520
TabIndex = 26
Top = 3120
Width = 1815
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "Key in Answer Here ===>"
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 25
Top = 8760
Width = 3615
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &HFF&
Caption = "Red Player Press ""Q"""
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0&
Height = 375
Left = 9600
TabIndex = 24
Top = 4440
Width = 3735
End
End
Option Explicit
Const DisplaySequence = " 1506130702190112041705181020090314161108"
Private BoardSFX As AudioSounds, animate As Integer
Re: Letters to Images Problem
try taking out the equels sign(=) & use a (&)
Open (App.Path & "\bbee\text\puzzleletters.txt") & Input(Str(Y))
Re: Letters to Images Problem
Quote:
Originally Posted by
JonSea31
I need some help in figuring out how to retrieve the letter for each block.
Code:
Sub Main()
Randomize
X = Int((19 * Rnd) + 1) 'you have 19 lines in the text file
' edit the following so it is the path to your file
Open (App.Path = "\bbee\text\puzzleletters.txt") & Input(Str(Y))
For Y = 1 To X 'this will get the x'th line
Input #1, NewPuzzle
Next Y
Close #1
NewLetter = 1
RoundOne.Show
End Sub
The bolded line is where I am having problems with retrieving the letter for each block. User Caskbill did create the code on my behalf, but originally it failed. I edited his code (shown in bold), and I am still experiencing problems. Where did we go wrong?
Also, I did a test run, and it detected an error on the line that reads "VERSION 5#." What was wrong there?
Here is the code from the forms file:
Code:
VERSION 5#
Begin VB.Form RoundOne
BackColor = &H8000000A
Caption = "Form1"
ClientHeight = 9270
ClientLeft = 60
ClientTop = 450
ClientWidth = 13515
DrawStyle = 5 'Transparent
FillColor = &H8000000B
LinkTopic = "Form1"
ScaleHeight = 9270
ScaleWidth = 13515
StartUpPosition = 3 'Windows Default
Begin Project1.UserControl1 UC
Height = 1095
Index = 1
Left = 1560
TabIndex = 31
Top = 960
Width = 1575
_ExtentX = 2778
_ExtentY = 1931
Picture = "RoundOne1.frx":0000
MaskColor = 16711680
MaskPicture = "RoundOne1.frx":56BA
ScaleHeight = 1095
ScaleWidth = 1575
End
Begin VB.PictureBox Picture1
BackColor = &H80FF80
BorderStyle = 0 'None
Height = 6735
Index = 1
Left = 0
ScaleHeight = 6735
ScaleWidth = 9495
TabIndex = 29
Top = 0
Width = 9495
Begin VB.Timer Timer2
Left = 720
Top = 120
End
Begin VB.Timer Timer1
Left = 0
Top = 0
End
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 495
Left = 9840
TabIndex = 23
Top = 6600
Width = 615
End
Begin VB.CommandButton Command2
Caption = "2"
Height = 495
Left = 9840
TabIndex = 22
Top = 7200
Width = 615
End
Begin VB.CommandButton Command3
Caption = "3"
Height = 495
Left = 9840
TabIndex = 21
Top = 7800
Width = 615
End
Begin VB.CommandButton Command4
Caption = "4"
Height = 495
Left = 9840
TabIndex = 20
Top = 8400
Width = 615
End
Begin VB.CommandButton Command5
Caption = "5"
Height = 495
Left = 10560
TabIndex = 19
Top = 6840
Width = 615
End
Begin VB.CommandButton Command6
Caption = "6"
Height = 495
Left = 10560
TabIndex = 18
Top = 7440
Width = 615
End
Begin VB.CommandButton Command7
Caption = "7"
Height = 495
Left = 10560
TabIndex = 17
Top = 8040
Width = 615
End
Begin VB.CommandButton Command8
Caption = "8"
Height = 495
Left = 10560
TabIndex = 16
Top = 8640
Width = 615
End
Begin VB.CommandButton Command9
Caption = "9"
Height = 495
Left = 11280
TabIndex = 15
Top = 6600
Width = 615
End
Begin VB.CommandButton Command10
Caption = "10"
Height = 495
Left = 11280
TabIndex = 14
Top = 7200
Width = 615
End
Begin VB.CommandButton Command11
Caption = "11"
Height = 495
Left = 11280
TabIndex = 13
Top = 7800
Width = 615
End
Begin VB.CommandButton Command12
Caption = "12"
Height = 495
Left = 11280
TabIndex = 12
Top = 8400
Width = 615
End
Begin VB.CommandButton Command13
Caption = "13"
Height = 495
Left = 12000
TabIndex = 11
Top = 6840
Width = 615
End
Begin VB.CommandButton Command14
Caption = "14"
Height = 495
Left = 12000
TabIndex = 10
Top = 7440
Width = 615
End
Begin VB.CommandButton Command15
Caption = "15"
Height = 495
Left = 12000
TabIndex = 9
Top = 8040
Width = 615
End
Begin VB.CommandButton Command16
Caption = "16"
Height = 495
Left = 12000
TabIndex = 8
Top = 8640
Width = 615
End
Begin VB.CommandButton Command17
Caption = "17"
Height = 495
Left = 12720
TabIndex = 7
Top = 6600
Width = 615
End
Begin VB.CommandButton Command18
Caption = "18"
Height = 495
Left = 12720
TabIndex = 6
Top = 7200
Width = 615
End
Begin VB.CommandButton Command19
Caption = "19"
Height = 495
Left = 12720
TabIndex = 5
Top = 7800
Width = 615
End
Begin VB.CommandButton Command20
Caption = "20"
Height = 495
Left = 12720
TabIndex = 4
Top = 8400
Width = 615
End
Begin VB.PictureBox RedScore
BorderStyle = 0 'None
Height = 615
Left = 9600
ScaleHeight = 615
ScaleWidth = 1815
TabIndex = 3
Top = 3720
Width = 1815
End
Begin VB.PictureBox WhiteScore
BorderStyle = 0 'None
Height = 615
Left = 11520
ScaleHeight = 615
ScaleWidth = 1815
TabIndex = 2
Top = 3720
Width = 1815
End
Begin VB.TextBox AnswerBar
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3720
TabIndex = 1
Text = "Text1"
Top = 8640
Width = 5775
End
Begin VB.PictureBox Picture60
BorderStyle = 0 'None
Height = 2655
Left = 9600
Picture = "RoundOne1.frx": AD74
ScaleHeight = 2655
ScaleWidth = 3735
TabIndex = 0
Top = 240
Width = 3735
End
Begin VB.Label Label3
Alignment = 2 'Center
BackColor = &HFFFFFF
Caption = "White Player Press ""P"""
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 9600
TabIndex = 30
Top = 4800
Width = 3735
End
Begin VB.Label QuestionBox
Alignment = 2 'Center
BackColor = &H800000
Caption = "Label1"
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80FFFF
Height = 1455
Left = 0
TabIndex = 28
Top = 6960
Width = 9495
End
Begin VB.Label RedPlayerLabel
Alignment = 2 'Center
BackColor = &HFF&
Caption = "Label1"
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 9600
TabIndex = 27
Top = 3120
Width = 1815
End
Begin VB.Label WhitePlayerLabel
Alignment = 2 'Center
BackColor = &HFFFFFF
Caption = "Label2"
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 11520
TabIndex = 26
Top = 3120
Width = 1815
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "Key in Answer Here ===>"
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 25
Top = 8760
Width = 3615
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &HFF&
Caption = "Red Player Press ""Q"""
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0&
Height = 375
Left = 9600
TabIndex = 24
Top = 4440
Width = 3735
End
End
Option Explicit
Const DisplaySequence = " 1506130702190112041705181020090314161108"
Private BoardSFX As AudioSounds, animate As Integer
Take off the pound sign (#) eg VERSION 5.00
Re: Letters to Images Problem
Removing the pound sign will only give me the error message: Invalid Outside Procedure.
And I revamped the file path, but the only drawback is, the file path comes from the H drive and not the C drive, since the C drive (the hard drive) crashed in 2007 due to a virus.
EDIT: I just removed the VERSION 5# line, and I did a test run, and I discovered that on the line that reads "Begin VB.Form RoundOne", I get the message that says "Expected: End of Statement" What does this mean?
PM coming, isnoend07. :)
Re: Letters to Images Problem
Quote:
Originally Posted by
JonSea31
Removing the pound sign will only give me the error message: Invalid Outside Procedure.
And I revamped the file path, but the only drawback is, the file path comes from the H drive and not the C drive, since the C drive (the hard drive) crashed in 2007 due to a virus.
EDIT: I just removed the VERSION 5# line, and I did a test run, and I discovered that on the line that reads "Begin VB.Form RoundOne", I get the message that says "Expected: End of Statement" What does this mean?
PM coming, isnoend07. :)
it looks to me like you need to create a new form and paste your code in
It looks like your form file has been corrupted and is missing the attributes that should be here:
End
End
Attribute VB_Name = "RoundOne"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
As far as the path goes App.Path will be point to where your vb project is.
If your vb project is on c:\ and you are trying to reference files D:\
then App.path will not work you will have to supply the full path name
Re: Letters to Images Problem
But I thought, in order for other users to play the game, he would have to retrieve the files from the C drive? Very few people have an H drive for a hard drive.
Re: Letters to Images Problem
Quote:
Open (App.Path = "\bbee\text\puzzleletters.txt") & Input(Str(Y))
to open a file your code should look like
Open filepathname For Input as filenumber
the correct way for your file is
vb Code:
dim fn as integer
fn = freefile ' get next file number
Open App.Path & "\bbee\text\puzzleletters.txt" For Input As fn
once it is opened then you need to read the file either by line or by reading the entire file into an array of lines
vb Code:
arrayoflines = split(input(lof(fn), #fn), vbnewline)
Close fn ' read whole file so close
to process the lines of the file
vb Code:
for i = 0 to ubound(arrayoflines) 'process all elements of array
' your code to put file data into textbox or whatever
next
'OR if you know which line you want to read, your random number
text1 = arrayoflines(X)
if you declare arrayoflines in the general section at the top of the form code, it will be available throughout your project
Re: Letters to Images Problem
I still do not know where I have to place this code you supplied. Can I send you a PM, westconn1?
Re: Letters to Images Problem
you could open the file and read into an array, in the form load event, then it is available to any other sub (button click or other event)
you can send me a PM, but much better to just ask here, as many more than me can answer
Re: Letters to Images Problem
I decided that the Blockbusters game I am developing is much too complex to create, and I think I am going to put it on hold for a while.
I think I am going to create a bit simpler game where there won't be as much linking to images, text, and all that stuff involved. Maybe I'll start to develop Card Sharks or something. I can relate to the Poker thread for reference on card games, only difference is that Card Sharks is like Acey Deucey.