Datagridview和随机访问textfiles vb6 [英] Datagridview and random access textfiles vb6

查看:105
本文介绍了Datagridview和随机访问textfiles vb6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!我存储有关我的用户的以下信息:



用户ID

FirstName

姓氏

地址第一行

地址第二行



我使用后端文本文件随机访问以存储我的数据。如何将我存储在文本文件中的数据显示到datagridview?每次我尝试任何东西它只会打印到第一行的第一列,我知道这是因为它将数据保存到文本文件中这样



我尝试过:



我尝试过使用vb.net技术,但它适用于流阅读器和编写器。

解决方案

没有随机访问文本文件这样的东西,因为所有记录的长度都不同。为了获得任何特定记录,你必须从文件开头读取每个记录并计算每个记录,直到你得到你想要的记录。



真正的随机访问文件只是记录数乘以每条记录的长度,从文件的开头到记录的第一个字节,您可以查找到的偏移量,而无需读取前面的所有内容到那里。



如果没有看到你的代码读取文件并在内存中构建一个可以绑定网格的表,就不可能告诉你你做错了什么。



哦,为什么你在使用VB6呢?这语言已经死了很长一段时间了。您可以从此处免费获取Visual Studio和VB.NET社区版[ ^ ]!


Hi ! I am storing the following information about my user:

UserID
FirstName
Surname
Address Line One
Address Line Two

I am using random access with back-end textfiles in order to store my data. How can I show my data that I have stored in my text files to my datagridview? every time I try anything it's only printing it to the first column in the first row and I know that's because its saving the data to the text file like this

What I have tried:

I have tried using vb.net techniques but it works with stream readers and writers.

解决方案

There's no such thing as a "random access" text file because all of the records are different lengths. In order to get to any specific record, you would have to read every record from the beginning of the file and count each one until you get to the one you want.

A true "random access" file is just the record number times the length of each record, giving you the offset form the beginning of the file to the first byte of the record to which you can Seek without reading everything in front of that to get there.

Without seeing your code that reads the file and builds a table in memory to which you can bind your grid, it's impossible to tell you what you did wrong.

Oh, and why on earth are you using VB6? The language has been dead for quite some time now. You can get the Community edition of Visual Studio and VB.NET for FREE from here[^]!


这篇关于Datagridview和随机访问textfiles vb6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆