Problem with records [Solved]
Okay im making some stupid turkey program as part of some collage work but I can't get this to work
Here is the code for the command button
VB Code:
Private Sub cmdGetNewTurkeys_Click()
Dim Password As String
Dim Inputpassword As String
Password = "venrick"
Inputpassword = InputBox("Please enter the password. Reamber after entering the password all other data in this program will be erased")
If Inputpassword = Password Then
Open App.Path & "\TurkeyList.dat" For Random As #1 Len = 58
Dim RecordNumber As Integer
RecordNumber = 0
Do
RecordNumber = RecordNumber + 1
Put #1, RecordNumber, TurkeyList
TurkeyList(RecordNumber).TurkeyID = RecordNumber
Dim Weight As Integer
Randomize
Weight = Int((5000 * Rnd) + 5001)
TurkeyList(RecordNumber).TurkeyWeight = Weight
TurkeyList(RecordNumber).TurkeySold = False
TurkeyList(RecordNumber).TurkeyCustomer = " "
TurkeyList(RecordNumber).TurkeyOrder = 0
Close #1
Loop Until RecordNumber = 40
Else
MsgBox ("The password you used is incorrect")
End If
End Sub
and here is the modual
VB Code:
Public Type TurkeyListType
TurkeyID As Integer
TurkeyWeight As Integer
TurkeySold As Boolean
TurkeyCustomer As String * 50
TurkeyOrder As Integer
End Type
Public TurkeyList(1 To 40) As TurkeyListType
How ever when i run the program it says "Error Bad file lenght" But i can't work it out :S this is the line of code that it says is wrong
VB Code:
Open App.Path & "\TurkeyList.dat" For Random As #1 Len = 58
What is wrong with that?
Can anyone help me?
Edit: Added [vbcode][/vbcode] tags for more clarity. - Hack
Re: Problem with records [Solved]
No problem!
a) welcome to the forums (just noticed it was your first post)
b) you are not a dummy/n00b you were close
c) you had everything you needed.. just not in the right order! thats pretty good!
also: fyi... just above your the first post is "Thread Tools" if u click that there is a Thread resolved option.. so next post.. you'll know how to easily mark the thread resolved! Enjoy! ;)