Find Code:
All Words
Any of the Words
Exact Phrase
Home
:
Code
:
Forums
:
Submit
:
Mailing List
:
About
:
Contact
Code
All
VB.NET
ASP.NET
C#
VB Classic
ASP Classic
Snippets
Popular
Resources
Submit Code
Forums
Articles
Tips
Links
Books
Contest
Link to us
Read binary data into an array that easy. A must ...
Author:
Ralf Koch
E-mail:
Click to e-mail author
Website:
http://www.kotech-enterprises.com
Submitted:
12/20/2001
Version:
VB5
Compatibility:
VB5, VB6
Category:
File Manipulation
Views:
12583
Read binary data into an array that easy. A must see and a must use!
Declarations:
' DECLARE ARRAY DYNAMICALLY ' THIS ALLOWS THE FUNCTION TO RESIZE IT Dim priceRec() As updPrice ' PRICE UPDATE RECORD ' CHANGE THIS FOR YOUR NEEDS ' THE INPUT FILE MUST MATCH THIS!!! Public Type updPrice partNumber As String * 15 price1 As String * 13 price2 As String * 13 description As String * 30 lang As String * 2 End Type
Code:
Function readPrice() As Boolean '-------------------------------------------------------------------------------- ' Project : XMLHandler ' Procedure : readPriceXML ' Description: READ PRICE FILE FROM S400 ' Created by : Ralf Koch ' ' Parameters : '-------------------------------------------------------------------------------- ReDim priceRec(0) fileName = updateDir & "price.txt" Set fs = CreateObject("Scripting.FileSystemObject") ' CHECK IF FILE EXISTS If fs.FileExists(fileName) = True Then fileNumber = FreeFile ' GET RECORD LENGTH recLength = Len(priceRec(0)) Open fileName For Random As fileNumber Len = recLength ' CALCULATE TOTAL NUMBERS OF RECORDS TO READ recTotal = LOF(fileNumber) / recLength ' RESIZE ARRAY ReDim priceRec(recTotal) For recCount = 1 To recTotal Get #fileNumber, recCount, priceRec(recCount) Debug.Print priceRec(recCount).partNumber, priceRec(recCount).price1, priceRec(recCount).price2, priceRec(recCount).description Next Close #fileNumber readPrice = True End If Exit Function errorHandler: Resume Next End Function
Home
|
Forums
|
Submit
|
Books
|
Mailing List
|
Advertising
|
About
|
Contact
© 2023 A1VBCode. All rights reserved.
Legal disclaimer & terms of use
Privacy statement