
Patrick B. answered 10/29/20
Math and computer tutor/teacher
You can use the Microsoft flex grid
Go online and look for MSFLXGRD.OCX, and download it for free...
Put it in C:\Windows\SYSWOW64
open up MS DOS prompt, and goto that folder.
Register the control using DOS command REGSVR32 msflxgrd.ocx
IN VB, right click the toolbox, and locate the control.
Adds the control to the toolbox...
then drag and drop it onto the form...
========================================
Here is some code that reads the record from the file into the array
Module Module1
Structure DataRec
Public EmployeeId As String
Public LastName As String
Public FirstName As String
Public AnnualIncome As Double
Public IncomeTax As Double
End Structure
Public DataRecCount As Integer
Public A(5000) As DataRec
Public Sub Parse(inbuff As String, ByRef dataRec As DataRec)
Dim tokens() As String
tokens = inbuff.Split(" ")
dataRec.EmployeeId = tokens(0)
dataRec.LastName = tokens(1)
dataRec.FirstName = tokens(2)
dataRec.AnnualIncome = Val(tokens(3))
dataRec.IncomeTax = dataRec.AnnualIncome * 0.05
End Sub
Public Sub ReadFile()
Dim fileReader As System.IO.StreamReader
fileReader = My.Computer.FileSystem.OpenTextFileReader("E:\\IncomeRecord.txt")
Dim inbuff As String
inbuff = "?"
DataRecCount = 0
While Not fileReader.EndOfStream
inbuff = fileReader.ReadLine()
MsgBox(inbuff)
Parse(inbuff, A(DataRecCount))
DataRecCount = DataRecCount + 1
End While
fileReader.Close()
End Sub
End Module
================================
Here is the code that populates the data grid:
Sub Data2Grid()
Dim iRow As Integer
myGrid.Row = 0
myGrid.Col = 0 : myGrid.Text = "Employee Id#"
myGrid.Col = 1 : myGrid.Text = "Last Name"
myGrid.Col = 2 : myGrid.Text = "First Name"
myGrid.Col = 3 : myGrid.Text = "Annual Income"
myGrid.Col = 4 : myGrid.Text = "Income Tax"
myGrid.Rows = DataRecCount + 1
For iRow = 0 To DataRecCount - 1
myGrid.Row = iRow + 1
myGrid.Col = 0 : myGrid.Text = A(iRow).EmployeeId
myGrid.Col = 1 : myGrid.Text = A(iRow).LastName
myGrid.Col = 2 : myGrid.Text = A(iRow).FirstName
myGrid.Col = 3 : myGrid.Text = A(iRow).AnnualIncome
myGrid.Col = 4 : myGrid.Text = A(iRow).IncomeTax
Next
End Sub
Private Sub FormMain_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
ReadFile()
Data2Grid()
End Sub
End Class