• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

READ WRITE wWith Binary Files Convert VB6 to VB.NET TYPE GET PUT????

Hello Experts,
Im using following way(code) to read and write to a binary file in VB6. Now we are Planing to Migrate to VB.NET. Whats the best and easiest way to read and write from a structured binary file? (in some cases they were already generated by VB6). Please Explain with Code Examples. Thanking You
Udana


in module~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      Global Product As Productx

        Type Productx
                lngVal1 As Long
                lngVal2 As Long
                strVal1 As String * 6
                lngVal3 As Long
                strVal2 As String * 342
        End Type
In Form~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'command buttons for control and Text boxes for display

Sub Record() 'to record data to Prod.dat
          Close #28: Open "C:\Prod.dat" For Random Shared As #28 Len = 360
      For i = 0 To 100000
      Product.lngVal1 = i
      Product.lngVal2 = i*23
      Product.lngVal3 = i+23
      Product.strVal1 = CSTR(i)
        Put #28, i, Product
      Next i
End Sub

Sub Read() 'read data from Prod.dat
          Close #28: Open "C:\Prod.dat" For Random Shared As #28 Len = 360
        Get #28, 21112, Product
      Text1.Text=Cstr(Product.lngVal1)
      Text2.Text=(Product.lngVal2)
      Text3.Text=(Product.lngVal3)
      Text4.Text=(Product.strVal1)
End Sub
0
udanabanana
Asked:
udanabanana
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now