home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / array / vbarray.frm (.txt) < prev    next >
Visual Basic Form  |  1980-01-04  |  7KB  |  159 lines

  1. VBArray
  2. VB Array
  3. Form1%
  4. OkCancel
  5. &Quit
  6. OkCancel
  7.     OtherDemo
  8. &Some Type Array
  9. LngIntDemo
  10. &Long Integer Array
  11. IntDemo
  12. &Integer Array
  13. ListBox
  14. Status
  15. Status
  16.     sTempFile
  17. hWndListBox
  18. nInitApp
  19. @    Form_Load
  20. nResult
  21. GetTempFileName9
  22. Status
  23. Caption
  24. OkCancel_Click
  25. Index
  26. IntDemo
  27. Value)
  28.     DoIntDemo
  29. VBARRAYU
  30. LngIntDemoF
  31. DoLngIntDemo
  32.     OtherDemo
  33. DoOtherDemo
  34. Form_Unloadh
  35. Cancel
  36.     tTempFile
  37. OFSTRUCT
  38. OpenFile
  39. OF_EXIST
  40. nRemoveTemp
  41.     OF_DELETE
  42. nBeforex
  43. nAfter
  44. nBytesM
  45. hFileOut
  46. hFileIn
  47. nIObytesB
  48. nFclose
  49. lMes8
  50.     OF_CREATEW
  51. OF_WRITE
  52. lwritey
  53. lclose
  54. OF_READe
  55. lread
  56. SendMessage
  57. LB_RESETCONTENT
  58. ListBox
  59. FALSE1
  60. lBefore
  61. lAfter
  62. tBefore
  63. SomeType
  64. tAfter
  65. nInteger
  66. sString
  67. lLong
  68. Before
  69. After
  70. Form_Paint
  71. GetFocus
  72. LB_SETTABSTOPS;
  73. fSize
  74. llseekD
  75. ptint
  76. OtherDemo_Click
  77. IntDemo_Click
  78. ListBox_Click
  79. FileSize
  80. LngIntDemo_Click
  81.     trailling
  82.     lFileSize
  83. OkCancel
  84.  VBARRAY *FAST* file I/O of arrays
  85.  Address questions/comments/improvements tom
  86.  Costas Kitsos, CIS ID: 73667,1755
  87.  Enjoy! 
  88.  holds a Windows supplied temp filename for the demo
  89.  listbox's hWnd so we can set tabs
  90.  Flag for Application Initialization
  91. DoIntDemo
  92.  Declare variables
  93.  Used by OpenFile function
  94.  holds the Integers before I/O
  95.  holds the Integers after I/OO
  96.  Integerst
  97.  Use the Random number generator to fill nBefore() with 50 integers
  98.  ** I/O Starts here
  99.  Create our temp file and open it for writingo
  100.  If we have a file handle proceed 
  101.  calculate the number of bytes to be written (NumberOfElements * Size)
  102.  Since we want to write the entire array the formula would be:
  103.  nBytes = UBound(Array) * Len(Array(element)).  If we only neededS
  104.  twenty elements then nBytes = 20 * Len(Array(element)).  Since we're)
  105.  dealing with fixed length arrays, element can be any legitimate
  106.  array element.i
  107.  Write nBefore() to disk using API's lwrite function. 
  108.  We only need to pass the first array element.  The nBytes
  109.  parameter tells Windows how many bytes to write, or as far
  110.  as we're concerned how many array elements.
  111.  Get the file size with llseek.  By specifying 0 for lOffset and
  112.  and 2 for iOrigin we're saying seek position 0 from the end ofh
  113.  the file.  In other words, give us the FileSize.r
  114.  close the output file. 
  115.  Now let's see if it worked.  Open the file for reading.
  116.  We'll use the nAfter() array this time, nBytes is the same.
  117.  close the input file.
  118.  Let's prove that it worked.  First, clear the list box.
  119.  Add a title.
  120. Before
  121. After
  122.  Add the nBefore() and nAfter() contents to the listbox.
  123. Temp File: 
  124.  bytes
  125.  success
  126.  failure
  127. DoLngIntDemo
  128.  Please see the DoIntDemo function for comments
  129. Before
  130. After
  131. Temp File: 
  132.  bytes
  133. DoOtherDemo
  134.  Please see the DoIntDemo function for comments
  135. abcde
  136. Before
  137. After
  138. Temp File: 
  139.  bytes
  140. Form_Load
  141.  Buffero
  142.  Ask Windows for a temp file. 
  143. Temp File: 
  144. Form_Paint
  145.  get the listbox's hWnd
  146.  Set 1 tab stop at position 105n
  147. set the flag to FALSE so we don't repeat thisn
  148. Form_Unload
  149.  Used by OpenFilei
  150.  If our temp file exists, delete it.
  151. OkCancel_Click
  152.  Do the Integer Array demo
  153. Integer Demo Failed
  154.  Do the Long Integer Array demot
  155. Long Integer Demo Failed
  156.  Do the SomeType Array demod
  157. Some Type Demo Failed
  158.  Quit pressedp
  159.