Results 1 to 7 of 7

Thread: Put & Get, please help, its kinda urgent

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    6

    Post

    Currently in my project, I am using Read and Write. This is far too slow when it comes to saving stuff cos i have to rewrite the file again and my file is huggee. my file looks kinda like this:

    "part1", "secondbit", "thirdbit", etc
    "walrus", "bigman", "mad"

    will using the Put statement make it possible to change a line in my file without rewriting the file again?, and how would i read the line again?

    i want all the data being read from the file to be stored into arrays i.e. FirstPart(1)="part1"
    FirstPart(2)="walrus"

    please help

  2. #2
    Lively Member
    Join Date
    Mar 2000
    Posts
    82

    Post

    is each line of your file related to each other in a way that would let you define a UDT?

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    6

    Post

    Sorry, whats a UDT? Im kinda new to visual basic

  4. #4
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    Post UDT

    A UDT is a User Defined Type. Here's how you make a UDT:

    Private Type MyType
    Name as String
    Age as Byte
    Height as Byte
    Weight as Long
    End Type

    You can now define a variable using this type. Example:

    Dim Person As MyType

    Person.Name = "Grandpa"
    Person.Age = "100"
    Person.Height = 72 'inches
    Person.Weight = 399 'pounds

    You get the picture now right?

    Hope this helps,
    Drew

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    6

    Post

    thanx verrry much for that , but how would u 'put' that in a file and 'get' that data back into arrays? like name(), age() etc

  6. #6
    Lively Member
    Join Date
    Mar 2000
    Posts
    82

    Post

    'define your UDT
    type person
    dim firstname as string * 10
    dim lastname as string * 10
    end type
    'create and instance of your UDT (person)
    dim p as person

    'open a file in random
    open "yourfile" for random as fp len = len(p)
    'len = len(p) defines the length of each record in the file
    'firstname and lastname use fixed length strings so each
    'record you write is the same length, and then can write
    'and retrive records in the middle of a file

    get fp, 5 , p
    'would read the 5th record of your file into the UDT var p
    'leaving out the record number, i think, writes to the end
    'file, but you might want to check on that

    put fp, 5, p
    'would write your UDT var p to the 5th record in your file

    'then if you need to put it into a array
    'but trim off the spaces (fixed len strings)
    array(0) = trim$(p.firstname)
    array(1) = trim$(p.lastname)

    any help???

  7. #7

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Posts
    6

    Post

    thanxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx veryyyyyy muchhhh i really needed that

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width