Results 1 to 6 of 6

Thread: fancy file stuff

  1. #1

    Thread Starter
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404

    Question fancy file stuff

    Any one know how to read a file as input and how to store the contents of the file.

    does each line get stored as a string in an array of strings??

  2. #2
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    If you want to open a text only file use...
    Code:
       Dim Str as String
       Open "C:\myfile.txt" for input as #1 'myfile.txt=the text file
       'To get all the text into a string
       Input #1, Str
       'To get by charectors into a string
       Str=Input(NumberOfChars, #1)
    #1=file number... hence it can go on as #2, #3, #4 etc, depending on the number of files you are opening

    To open in binary mode use... (Required for exe,dll,com etc files)
    Code:
       Dim Str as String
       Open "C:\myfile.txt" for binary as #1 'myfile.txt=the text file
       Str=Space(FileLen("C:\myfile.txt"))
       Get #1,,Str
    THE TIME/WEATHER IS
    Don't know how to use APIs or have problem with them,
    Download API-Guide & API-Viewer from http://www.allapi.net

  3. #3

    Thread Starter
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    cheers, I'll give it a whirl!

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    http://www.vbforums.com/showthread.p...open+and+input

    No, it gets stored in a single string variable in the examples on the above page. If you wanted this into an array of strings, you could use something like :

    Split(strFileStringVariable, Chr(13))

    The split function splits a string into an array of strings, the new array elements are created whenever a new line (chr(13)) is found within that string variable.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5

    Thread Starter
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    cheers, Alex!

    do you know anything about obtaining modem properties with VB!

  6. #6
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    A lot of the Com port & modem talking / checking etc is either done with the winsock control (which I've never used before myself). Or the API.

    If you go to www.allapi.com and download the toolshed, you can do a search from the file menu for all API calls which have something to do with modems. Samples for each API call are included (fantastic program).

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

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