Guest makai Posted December 6, 2002 Posted December 6, 2002 (edited) the following code works just fine: Public Class Form1 Inherits System.Windows.Forms.Form Structure x Dim j As Short End Structure Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Dim y As x FileOpen(1, "c:\t1.txt", OpenMode.Random, , , Len(y)) FileGet(1, y, 1) FileClose(1) MsgBox(y.j) End Sub End Class but if I put in Option Strict On the line FileGet(1, y, 1) will not compile due to the fact that y is not in the overloaded parameter list 1. Does anyone know the correct conversion code? 2. I like the idea of sticking with Strict On - is this not a good idea? Edited December 10, 2002 by Thinker Quote
*Gurus* divil Posted December 6, 2002 *Gurus* Posted December 6, 2002 The best answer is, don't use FileOpen etc. They are pretty poor methods supplied by the VisualBasic runtime of accessing files, and there are much better methods present under the System.IO namespace. I'm not sure how you'd solve your problem if you remained using the VB methods, possibly just read in a Short (which there is an overload for) and put it in the structure. And yeah, you should always have Option Strict on. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest makai Posted December 6, 2002 Posted December 6, 2002 funny everyone heavily derides my use of these File functions - but it is the only way I can access the data I am willing to bet that no one has tried Random Access of data into Structures with fixed length strings (or fixed arrays) - that would make a great tutorial if someone can do it with any kind of elegance I have built a class to do sequential access using FileStream but to me it looks so crazy to reinvent something that is already intrinsic (and simpler) already in the language everyone points to speed - but it is a nonissue - it is already 100 times faster than I require Quote
Guest makai Posted December 7, 2002 Posted December 7, 2002 if anyone reads this thread this is the answer: Dim temp As ValueType = CType(y, ValueType) FileGet(fHandle, temp, n) y = CType(temp, x) Quote
rt3 Posted August 18, 2008 Posted August 18, 2008 Wow, i know this is an old post but in case you ever read this makai, i have one word for you. Thanks! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.