Can anyone point me in the right way as to why this code doesn't work?
VB Code:
Private Type record name As String * 15 gender As String * 1 status As String children As Integer End Type Dim field As record Dim x As Integer Dim fileno As Integer Dim recordlen As Long Dim recnum As Integer Dim y As Integer Dim z As Integer Private Sub Form_Load() Dim name() As String Dim gender() As String Dim status() As String Dim children() As Integer Dim value As String Dim fileno As Integer fileno = FreeFile value = 2 x = 1 y = 0 dlg2.FileName = "c:\My Documents\storage.txt" file_2_open = dlg2.FileName recordlen = Len(field) recnum = FileLen(file_2_open) / recordlen Open file_2_open For Random As fileno Len = recordlen For z = x To recnum Get fileno, x, field.name & field.gender & field.status & field.children If field.gender = "M" Then If field.children > value Then lblName1(y).Caption = Trim(field.name) lblGender1(y).Caption = Trim(field.gender) lblStatus1(y).Caption = Trim(field.status) lblChildren1(y).Caption = Trim(field.children) y = y + 1 Else: End If Else: End If x = x + 1 If y = 2 Then Exit For End If Next z Close fileno End Sub
basically, I hv these records in storage.txt... each record consisting of 4 fields.....
now i can't retrieve them...
i get this compile error "variable required - can't assign to expression" and when choosiung to debug in VB, it points to the & in:
Get fileno, x, field.name & field.gender & field.status & field.children




Reply With Quote