Using external files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kanuk
    New Member
    • Mar 2007
    • 4

    Using external files

    I know there has to be a way to do this

    I want to beable to store and input data from a txt file and then beable to load it and parce it into visual basic to be thrown into a 1,2,or 3 dimentinal array

    I used to beable to know how to do this.. but its been a while since i have done any coding

    I dont know if this will help but if any of you used to use qbasic.. there was a function that let you list data at the bottem of the program and you could call the data listed into variables and arrays

    I want to beable to do this in vb and it looks like there is no data list function so external files seem to be the way to go

    Basicly i want the end user to beable to input their own data into the external file and then the program loads it up and runs with it...

    what would be the easiest way to go about this?
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Yes, I remember that - the READ and DATA statements. Very handy for setting uo initial values in lists, and so on. Unfortunately, VB doesn't support them. The simplest way to set up an array, of course, is just to write it out like so...
    Code:
    ArrayEntry(1) = "Value 1"
    ArrayEntry(2) = "Value 2"
    .
    .
    .
    ArrayEntry(n) = "Value [I]n[/I]"
    But obviously this can become quite long-winded.

    You can also store them in the registry, or (as you said) in an external file such as a text file. Then you run into the complications of ensuring the file is where you expect to find it, and what to do if someone tampers with the contents.

    You probably should also look into the use of resource files in VB.

    A lot of the details will depend on what version of VB you are using.

    Comment

    • Kanuk
      New Member
      • Mar 2007
      • 4

      #3
      Well im just installing visual studio 2005.. so whichever version that is.. i think VB.net.. but not 100% sure ill know in probubly 30 min when its done installing

      anyways... actually the reason that I want the information in external files is so that the end user can tamper with it.. i want this programs information easily modified to suite the end user.. obviously this means ill have to include documentation on how to go about this without crashing the program.. but one bridge at a time..

      soo that being said.. hows the easiest way of going about doing that?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        I suppose the easiest way, though of course far from the most secure or reliable, would be to just store the stuff in a simple text file with some sort of heading so your program can recognise it. Something like the old Ini file format, perhaps...
        Code:
        [SectionName]
        Setting=Value
        Setting=Value
        .
        .
        .
        However, I'm only familiar with VB6, which is a considerably older version. VB 2005 (which is a .Net version - MS have decided to change the naming standards) may have better capabilities for this kind of thng.

        It might be a good idea to ask about it in the .Net forum, as well.

        Comment

        • Kanuk
          New Member
          • Mar 2007
          • 4

          #5
          OK thanks i will

          Comment

          Working...