FilePut返回类型' System.ArgumentException'的未处理异常。

时间:2013-12-12 20:23:32

标签: visual-studio-2013 record argumentexception

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

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

  

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

我的子程序代码如下:

    '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)

我该如何解决这个问题?

0 个答案:

没有答案