这是一个奇怪的错误,我不认为它与我的代码有任何关系,因为它发生在我的程序的几个部分。我在Visual Studio 2010中,在VB.net开发设置中工作,程序只执行部分代码。
我在加载表单时调用函数GenerateBarcode
。下面是函数GenerateBarcode:
'Generate random barcode
Dim i As Integer
Dim BarcodeIntegerStore(10) As Integer
Dim Barcode As String
重新启动:
'Generate the 10 integers of the barcode
'Form "BB" & 10 x integers
For i = 1 To 10
'Find a random number between 0 and 9
BarcodeIntegerStore(i) = CInt(Math.Ceiling(Rnd() * 9))
'Barcode is cumulative and so gains in size with each i value
Barcode = Barcode & Str(BarcodeIntegerStore(i))
Next
'Remove all spaces from barcode
Barcode = Barcode.Replace(" ", "")
'Add the BB at the start
Barcode = "BB" & Barcode
'Check barcode isn't already in use
Dim UserToSearch As New User
'Open the Users file
FileOpen(1, UserFileName, OpenMode.Random, OpenAccess.Read, OpenShare.Default, Len(UserToSearch))
For i = 1 To (LOF(1) \ Len(UserToSearch))
'Get the record
FileGet(1, UserToSearch, i)
'Check it already isn't in use
If txt_UserBarcode.Text = UserToSearch.UserBarcode Then
GoTo Restart
End If
Next
'Populate the barcode textbox
txt_UserBarcode.Text = Barcode
FileClose(1)
代码在FileOpen(1, UserFileName, OpenMode.Random, OpenAccess.Read, OpenShare.Default, Len(UserToSearch))
停止执行,这是一个问题,因为我有代码要在表单加载时执行te函数调用。