Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7716271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:35:40+00:00 2026-06-01T02:35:40+00:00

I need to read data from a legacy database file produced by Visual Basic

  • 0

I need to read data from a legacy database file produced by Visual Basic 6.
From the legacy software I found that file was written using Put and passing sort of records as parameters to the Put function. These structures are defined as follows:

Type THE_TYPE
    FIELD_1 As Single
    FIELD_2 As String * 20
    FIELD_3(1 To 50) As Single
    FIELD_4(1 To 10) As String * 1
End Type

My Types are larger and more complex but I’ve put in THE_TYPE the different definitions I have in my project. I’ve found that importing Microsoft.VisualBasic gives me access to VB functions similar to those used to write the file, so I’m opening and closing the file with FileSystem.OpenFile() and .CloseFile(); now I need to finally read data contained and since the original function was:

Public RecordContent As THE_TYPE
[...] 
Get #1, recordNumber, RecordContent 

I suppose I can use something similar, like Microsoft.VisualBasic.FileSystem.FileGet().
So the question is, how do I define a container, I suppose a class, similar to the original VB6 Type THE_TYPE? How do I call .FileGet() to correctly fill this object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:35:41+00:00Added an answer on June 1, 2026 at 2:35 am

    The key is defining attributes properly on the structure declaration in VB.NET. Provided the structure will always be initialized by FileGet, you don’t need to manually initialize its fixed fields in a constructor, otherwise, you do.

    Structure THE_TYPE
        Public FIELD_1 As Single
        <VBFixedString(20), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst:=20)> Public FIELD_2 As String
        <VBFixedArray(49)> Public FIELD_3 As Single()
        <VBFixedArray(9)> Public FIELD_4 As Char()
    End Structure
    

    Obviously, the arrays will have to start from zero, so the upper bounds are shifted down.

    Reading from the file:

    Dim d As System.ValueType = New THE_TYPE()
    
    FileOpen(1, "...", OpenMode.Random, OpenAccess.Read, OpenShare.Default, 234)
    FileGet(1, d, 1)
    FileClose(1)
    

    234 is the size of the structure in VB6. It’s bigger in VB.NET, so you want to hardcode that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to read data from an online database that's displayed using an aspx
I need to read the data from a file that can be either comma
As part of an assignment, I need to read data from a binary file
I need to read some data from an input file and plot a graph
I need to read small sequences of data from a 3.7 GB file. The
I need to read data from a text file where the field lengths and
I'm building a program that has several functions that need to read data from
I need to read text data from file, where there are different types of
I need to read data from a CSV file & display it as a
I read text data from big file line by line. But I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.