home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,061 of 10,840   
   J French to All   
   Re: Declaring variables and file for ran   
   06 Dec 04 14:24:04   
   
   XPost: comp.lang.basic.visual, comp.lang.basic.visual.misc   
   From: erewhon@nowhere.uk   
      
   On Mon, 6 Dec 2004 11:49:27 +0100, "Stefanie"    
   wrote:   
      
   >Steve,   
   >   
   >Thats the same as writing data to the file using Put, right ?   
   >   
      
   I could not see your first post   
      
   Below is a demo of Random Access using UDTs containing variable length   
   strings - the Record Length that it is opened with has to be large   
   enough.   
   - I would not do it like this personally   
      
   Option Explicit   
      
   Private Type TRec   
      L As Long   
      S As String   
      I As Integer   
   End Type   
      
   Private Sub Command1_Click()   
      Dim Rec As TRec, Channel%   
      
      Rec.L = -1   
      Rec.S = "Test String"   
      Rec.I = -1   
      
      Channel = FreeFile   
      Open App.Path + "\test.dat" For Random As Channel Len = 200   
      Put #Channel, 1, Rec   
      Close #Channel   
      
   End Sub   
      
   Private Sub Command2_Click()   
      Dim Rec As TRec, Channel%   
      
      Channel = FreeFile   
      Open App.Path + "\test.dat" For Random As Channel Len = 200   
      Get #Channel, 1, Rec   
      Close #Channel   
      Me.Print Rec.L, Rec.S, Rec.I   
      
   End Sub   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca