Keep getting error message when trying to run this bit of code
-
I don't know what is wrong with this code. Keep getting error messages as follows: bc30026 End sub expected bc30289 Statement cannot appear within a method body. End of method assumed. bc42024 unused local variable: 'position'. bc42109 Variable 'temp' is used before it has been assigned a value. any help would be appreciated. Thanks
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim position As Integer Structure person Dim id As Integer Dim name As String Dim surname As String End Structure Private Function FindLastRecordNo() Dim temp As person, FileNumber As Integer FileNumber = FreeFile() FileOpen(FileNumber, TextBox1.Text, OpenMode.Random, \_OpenAccess.Read,, Len(temp)) FindLastRecordNo = 1 Do While Not EOF(FileNumber) FileGet(FileNumber, temp, ) FindLastRecordNo = FindLastRecordNo + 1 Loop FileClose(FileNumber) End Function End Sub
-
I don't know what is wrong with this code. Keep getting error messages as follows: bc30026 End sub expected bc30289 Statement cannot appear within a method body. End of method assumed. bc42024 unused local variable: 'position'. bc42109 Variable 'temp' is used before it has been assigned a value. any help would be appreciated. Thanks
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim position As Integer Structure person Dim id As Integer Dim name As String Dim surname As String End Structure Private Function FindLastRecordNo() Dim temp As person, FileNumber As Integer FileNumber = FreeFile() FileOpen(FileNumber, TextBox1.Text, OpenMode.Random, \_OpenAccess.Read,, Len(temp)) FindLastRecordNo = 1 Do While Not EOF(FileNumber) FileGet(FileNumber, temp, ) FindLastRecordNo = FindLastRecordNo + 1 Loop FileClose(FileNumber) End Function End Sub
[Statement cannot appear within a method body | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/visual-basic/misc/bc30289) ['End Sub' expected | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/visual-basic/misc/bc30026)... ... Or do you avoid reading the docs?