Name: Anonymous 2006-02-07 17:15
so yeah. i'm writing my first evar real program in VB, and everything's going swimmingly, but for some reason VB locks up on me when i try and run this program and activate this sequence of code:
Public Sub recwrite()
Dim n As Integer
Dim g As Integer
planet1.galaxy = galaxytext.Text
planet1.ssystem = ssystemtext.Text
planet1.planet = planettext.Text
planet1.owner = ownertext.Text
planet1.name = Nametext.Text
planet1.rating = ratingtext.Text
Call idassigner(g)
planet1.id = g
Open App.Path & "\planetdatabase.ogf" For Random As #1 Len = Len(planet1)
n = LOF(1) / Len(planet1)
Put #1, n + 1, planet1
Close #1
End Sub
Private Sub idassigner(ByRef g As Integer)
Open App.Path & "\planetdatabase.ogf" For Random As #1 Len = Len(planet1)
Dim n As Integer 'this is the number of records
Dim i As Integer 'this is the record being looked at currently
n = LOF(1) / Len(planet1)
i = 1
g = 1
Get #1, i, planet1
Do
Get #1, i, planet1
If planet1.id = g Then g = g + 1 And i = 1
If planet1.id <> g Then i = i + 1
Loop Until i > n
Close #1
End Sub
i've figured that the problem occurs either at the loop until i > n part or the close #1 part. i'm using VB 6.0 help 'preciated.
Public Sub recwrite()
Dim n As Integer
Dim g As Integer
planet1.galaxy = galaxytext.Text
planet1.ssystem = ssystemtext.Text
planet1.planet = planettext.Text
planet1.owner = ownertext.Text
planet1.name = Nametext.Text
planet1.rating = ratingtext.Text
Call idassigner(g)
planet1.id = g
Open App.Path & "\planetdatabase.ogf" For Random As #1 Len = Len(planet1)
n = LOF(1) / Len(planet1)
Put #1, n + 1, planet1
Close #1
End Sub
Private Sub idassigner(ByRef g As Integer)
Open App.Path & "\planetdatabase.ogf" For Random As #1 Len = Len(planet1)
Dim n As Integer 'this is the number of records
Dim i As Integer 'this is the record being looked at currently
n = LOF(1) / Len(planet1)
i = 1
g = 1
Get #1, i, planet1
Do
Get #1, i, planet1
If planet1.id = g Then g = g + 1 And i = 1
If planet1.id <> g Then i = i + 1
Loop Until i > n
Close #1
End Sub
i've figured that the problem occurs either at the loop until i > n part or the close #1 part. i'm using VB 6.0 help 'preciated.