Results 1 to 6 of 6

Thread: [RESOLVED] Saving

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    124

    Resolved [RESOLVED] Saving

    I've got 3 records, that i would like to save as .DAT files, however i have no idea on how to do this. Would any one be able to help me. The three files i need to save are as follows.

    VB Code:
    1. Public Type CustomerInfoType
    2.     username As String * 15
    3.     password As String * 15
    4.     Name As String * 40
    5.     Email As String * 50
    6.     ContactAreaCode As String * 5
    7.     ContactPhoneNumber As String * 6
    8.     HouseNumber As Integer
    9.     StreetName As String * 30
    10.     County As String * 30
    11.     Postcode As String * 8
    12.     used As Boolean 'True if the Recored is used
    13. End Type
    14. Public CustomerInfo(1 To 1092) As CustomerInfoType
    15.  
    16. Public Type BookingInfoType
    17.     username As String * 15
    18.     BookingCode As String * 7
    19.     BookingMonth As Integer
    20.     TitleOfEvent As String * 40
    21.     Extension As Boolean 'True if the booking has an extension
    22.     Specail As Boolean 'True if the booking is a specail
    23.     FeePaid As Boolean 'True if the booking has been paid for
    24.     Booked As Boolean 'True if this booking is booked
    25.     used As Boolean 'True if the Recored is used
    26. End Type
    27. Public BookingInfo(1 To 1092) As BookingInfoType
    28.  
    29. Public Type BookedType
    30.     SunAMor As Boolean
    31.     MonAMor As Boolean
    32.     TueAMor As Boolean
    33.     WedAMor As Boolean
    34.     ThuAMor As Boolean
    35.     FriAMor As Boolean
    36.     SatAMor As Boolean
    37.     SunBMor As Boolean
    38.     MonBMor As Boolean
    39.     TueBMor As Boolean
    40.     WedBMor As Boolean
    41.     ThuBMor As Boolean
    42.     FriBMor As Boolean
    43.     SatBMor As Boolean
    44.     SunCMor As Boolean
    45.     MonCMor As Boolean
    46.     TueCMor As Boolean
    47.     WedCMor As Boolean
    48.     ThuCMor As Boolean
    49.     FricMor As Boolean
    50.     SatCMor As Boolean
    51.     SunDMor As Boolean
    52.     MonDMor As Boolean
    53.     TueDMor As Boolean
    54.     WedDMor As Boolean
    55.     ThuDMor As Boolean
    56.     FriDMor As Boolean
    57.     SatDMor As Boolean
    58.     SunEMor As Boolean
    59.     MonEMor As Boolean
    60.     TueEMor As Boolean
    61.     WedEMor As Boolean
    62.     ThuEMor As Boolean
    63.     FriEMor As Boolean
    64.     SatEMor As Boolean
    65.     SunFMor As Boolean
    66.     MonFMor As Boolean
    67.     TueFMor As Boolean
    68.     WedFMor As Boolean
    69.     ThuFMor As Boolean
    70.     FriFMor As Boolean
    71.     SatFMor As Boolean
    72.    
    73.     SunAAft As Boolean
    74.     MonAAft As Boolean
    75.     TueAAft As Boolean
    76.     WedAAft As Boolean
    77.     ThuAAft As Boolean
    78.     FriAAft As Boolean
    79.     SatAAft As Boolean
    80.     SunBAft As Boolean
    81.     MonBAft As Boolean
    82.     TueBAft As Boolean
    83.     WedBAft As Boolean
    84.     ThuBAft As Boolean
    85.     FriBAft As Boolean
    86.     SatBAft As Boolean
    87.     SunCAft As Boolean
    88.     MonCAft As Boolean
    89.     TueCAft As Boolean
    90.     WedCAft As Boolean
    91.     ThuCAft As Boolean
    92.     FricAft As Boolean
    93.     SatCAft As Boolean
    94.     SunDAft As Boolean
    95.     MonDAft As Boolean
    96.     TueDAft As Boolean
    97.     WedDAft As Boolean
    98.     ThuDAft As Boolean
    99.     FriDAft As Boolean
    100.     SatDAft As Boolean
    101.     SunEAft As Boolean
    102.     MonEAft As Boolean
    103.     TueEAft As Boolean
    104.     WedEAft As Boolean
    105.     ThuEAft As Boolean
    106.     FriEAft As Boolean
    107.     SatEAft As Boolean
    108.     SunFAft As Boolean
    109.     MonFAft As Boolean
    110.     TueFAft As Boolean
    111.     WedFAft As Boolean
    112.     ThuFAft As Boolean
    113.     FriFAft As Boolean
    114.     SatFAft As Boolean
    115.  
    116.     SunAEve As Boolean
    117.     MonAEve As Boolean
    118.     TueAEve As Boolean
    119.     WedAEve As Boolean
    120.     ThuAEve As Boolean
    121.     FriAEve As Boolean
    122.     SatAEve As Boolean
    123.     SunBEve As Boolean
    124.     MonBEve As Boolean
    125.     TueBEve As Boolean
    126.     WedBEve As Boolean
    127.     ThuBEve As Boolean
    128.     FriBEve As Boolean
    129.     SatBEve As Boolean
    130.     SunCEve As Boolean
    131.     MonCEve As Boolean
    132.     TueCEve As Boolean
    133.     WedCEve As Boolean
    134.     ThuCEve As Boolean
    135.     FricEve As Boolean
    136.     SatCEve As Boolean
    137.     SunDEve As Boolean
    138.     MonDEve As Boolean
    139.     TueDEve As Boolean
    140.     WedDEve As Boolean
    141.     ThuDEve As Boolean
    142.     FriDEve As Boolean
    143.     SatDEve As Boolean
    144.     SunEEve As Boolean
    145.     MonEEve As Boolean
    146.     TueEEve As Boolean
    147.     WedEEve As Boolean
    148.     ThuEEve As Boolean
    149.     FriEEve As Boolean
    150.     SatEEve As Boolean
    151.     SunFEve As Boolean
    152.     MonFEve As Boolean
    153.     TueFEve As Boolean
    154.     WedFEve As Boolean
    155.     ThuFEve As Boolean
    156.     FriFEve As Boolean
    157.     SatFEve As Boolean
    158.  
    159.  
    160. End Type
    161. Public Booked(1 To 12) As BookedType


    Thanks to anyone that can help me

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Saving

    What information do you want to save?

    I see a bunch of variable and type declarations but no data.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    124

    Re: Saving

    well CustomerInfo(1).username for example would hold the username for record number one. I need to save al of them, 1 to 1092, and save all of the other information too.


    The gets written into these records in othr places of my program, for example

    VB Code:
    1. Do While quit = False
    2.     index = index + 1
    3.         If BookingInfo(index).used = False Then 'Number 1
    4.             CurrentUser(0).BookingInfoNumber = index
    5.             BookingInfo(index).username = Data(0).username
    6.             BookingInfo(index).BookingCode = code
    7.             BookingInfo(index).BookingMonth = Data(0).ChosenMonthNum
    8.             BookingInfo(index).TitleOfEvent = frmBooking.txtTitleOfEvent.Text
    9.             quit = True
    10.         ElseIf index = 1092 Then
    11.             MsgBox ("An error has occurred - Book.bas Public Sub UserNumbers() - 1")
    12.             End
    13.         End If
    14.     Loop

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Saving

    You said you needed three of them and I don't know how you need them divided up, but hopefully, this will give you a start
    VB Code:
    1. Open "c:\customer.dat" For Append As #1
    2.    Print #1, CustomerInfo(1).username
    3.    'etc
    4.    'etc
    5. Close #1

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    124

    Re: Saving

    okay, thanks. And if i wanted to populate the records again when i re-load the program how would i do that?

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Saving

    I don't know what mixture of controls you have so I'll just give an example that you can use as a model to reload everything. This loads the contents of a text file into a listbox. Modify as necessary
    VB Code:
    1. Dim strItems As String
    2.  
    3. Open "c:\customer.dat" For Input As #1
    4.     While Not EOF(1)
    5.       Line Input #1, strItems
    6.       List1.AddItem strItems
    7.     Wend
    8.     Close #1

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