ເນື້ອໃນ

# ຟັງຊັນ Lof

ສົ່ງຄືນຂະໜາດຂອງໄຟລ໌ທີ່ເປີດຢູ່ເປັນຫົວໜ່ວຍໄບຕ໌.

### ໄວຍາກອນ:

    Lof (FileNumber) As Long

### ປະເພດຄ່າທີ່ສົ່ງກັບ:

Long

### ພາຣາມິເຕີ:

FileNumber: ນິພົດຕົວເລກໃດໜຶ່ງທີ່ປະກອບມີໝາຍເລກໄຟລ໌ທີ່ລະບຸໄວ້ໃນຄຳສັ່ງ Open.

ເພື່ອຫາຄວາມຍາວຂອງໄຟລ໌ທີ່ບໍ່ໄດ້ເປີດຢູ່, ໃຫ້ໃຊ້ຟັງຊັນ FileLen.

### ລະຫັດຂໍ້ຜິດພາດ:

5 ການເອີ້ນໃຊ້ໂປຣຊີເຈີບໍ່ຖືກຕ້ອງ

52 ຊື່ໄຟລ໌ ຫຼື ເລກໄຟລ໌ບໍ່ຖືກຕ້ອງ

### ຕົວຢ່າງ:

      Sub ExampleRandomAccess
          Dim iNumber As Integer
          Dim sText As Variant ' ຕ້ອງເປັນແບບ variant
          Dim aFile As String
          aFile = "C:\Users\ThisUser\data.txt"
          iNumber = Freefile
          Open aFile For Random As #iNumber Len=32
          Seek #iNumber,1 ' ໄປທີ່ຕຳແໜ່ງເລີ່ມຕົ້ນ
          Put #iNumber, , "This is the first line of text" ' ຂຽນຂໍ້ຄວາມລົງໃນແຖວ
          Put #iNumber, , "This is the second line of text"
          Put #iNumber, , "This is the third line of text"
          Seek #iNumber,2
          Get #iNumber, , sText
          Print sText
          Close #iNumber
          iNumber = Freefile
          Open aFile For Random As #iNumber Len=32
          Get #iNumber, 2, sText
          Put #iNumber, , "This is a new text"
          Get #iNumber, 1, sText
          Get #iNumber, 2, sText
          Put #iNumber, 20, "This is the text in record 20"
          Print Lof(#iNumber)
          Close #iNumber
      End Sub

      Sub ExampleRandomAccess
          Dim iNumber As Integer
          Dim sText As Variant ' ຕ້ອງເປັນແບບ variant
          Dim aFile As String
          aFile = "~/data.txt"
          iNumber = Freefile
          Open aFile For Random As #iNumber Len=32
          Seek #iNumber,1 ' ໄປທີ່ຕຳແໜ່ງເລີ່ມຕົ້ນ
          Put #iNumber, , "This is the first line of text" ' ຂຽນຂໍ້ຄວາມລົງໃນແຖວ
          Put #iNumber, , "This is the second line of text"
          Put #iNumber, , "This is the third line of text"
          Seek #iNumber,2
          Get #iNumber, , sText
          Print sText
          Close #iNumber
          iNumber = Freefile
          Open aFile For Random As #iNumber Len=32
          Get #iNumber, 2, sText
          Put #iNumber, , "This is a new text"
          Get #iNumber, 1, sText
          Get #iNumber, 2, sText
          Put #iNumber, 20, "This is the text in record 20"
          Print Lof(#iNumber)
          Close #iNumber
      End Sub

ຫົວຂໍ້ທີ່ກ່ຽວຂ້ອງ

ຄຳສັ່ງ Close

ຄຳສັ່ງ Print#

ຄຳສັ່ງ Open

ຄຳສັ່ງ Get

ກະລຸນາສະໜັບສະໜູນພວກເຮົາ!