1

我在 Visual Studio 2013 上用 Visual Basic 编写。

我在一个模块中定义了客户记录结构。我正在尝试保存到固定长度的记录。但是,当我尝试保存时,它会返回突出显示 FilePut 并显示错误消息:

“Microsoft.VisualBasic.dll 中发生了‘System.ArgumentException’类型的未处理异常”。

我的子程序代码如下:

    'Open customer file to find what ID to use
    FileOpen("1", "CustomerRecord.dat", OpenMode.Random, OpenAccess.ReadWrite)

    'Find length of customer file
    Dim RecordLength As Integer = Len(Customer)

    'Populate customer ID with algorithm to find unique ID to use (Last ID used + 1)
    txt_CustomerID.Text = Str(LOF(1) / RecordLength + 1)

    'Find record number to write
    Dim RecordToWrite As Integer = (LOF(1) / RecordLength + 1)

    'Populate all the customer variables with the corresponding
    'textbox information
    Customer.CusID = Int(txt_CustomerID.Text)
    Customer.Title = cmb_Title.Text
    Customer.Forename = txt_Forename.Text
    Customer.Surname = txt_Surname.Text
    Customer.Postcode = txt_Postcode.Text
    Customer.NameNo = txt_HouseName.Text
    Customer.Town = txt_Town.Text
    Customer.DOB = txt_DOB.Text
    Customer.TelNo = txt_TelNo.Text
    Customer.Email = txt_Email.Text

    FilePut("1", Customer, RecordToWrite)

    FileClose(1)

我将如何解决这个问题?

4

0 回答 0