home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Binary_fil52375222002.psc / modMain.bas < prev   
Encoding:
BASIC Source File  |  2002-02-02  |  7.8 KB  |  263 lines

  1. Attribute VB_Name = "modMain"
  2. Option Explicit
  3.  
  4. '-------------------------------------------------------------
  5. 'This program is simply a map creator and editor that works
  6. 'with binary files. I wrote this program not for my own use,
  7. 'but as a reference to anyone that needs to learn how to
  8. 'access binary files and retreive information from them
  9. 'accruately and effecinently. My spelling isn't the best
  10. 'in the world today, so please try and bear with me.
  11. 'This program was written in Visual Basic 6.0 Enterprise
  12. 'Edition. Enough technical stuff...here is a little info about me:
  13. 'My name is Joe Estock and I (obviously) am a computer programmer.
  14. 'I write many commercial applications, as well as code fragments and
  15. 'small business applications. I started programming about six or seven
  16. 'years ago and have stuck with it ever since. The first programming
  17. 'environment I started in was Borland C++; I do not recall the version
  18. 'but it was a rather old version (a new one at the time). I then moved
  19. 'on to Visual C++ 6.0 and became rather bored as well as upset
  20. 'with the way the code is organized so I gave Visual Basic a try
  21. 'since I used to write QBASIC applications. Visual Basic quickly
  22. 'became an indispensable tool for me that has paid for itself
  23. 'many times. And here I am now. I release the source code to most
  24. 'of my products (I am not greedy or stingy like Microsoft, even though
  25. 'I do like them, but ony because of Visual Studio and Windows 2000
  26. 'Advanced Server), however I do not release the source code to many
  27. 'of my commercial products because I usually sell the source code to
  28. 'anotehr company and they throw their copyrights on it and do not
  29. 'allow me to share. This is it, I have taken up a ratehr large chunk
  30. 'of your screen, and you probabally haven't even read anything I have
  31. 'written beyond "This program". How do I know? Because I am the same way.
  32. 'I like to dive right in and learn what I need to know, dry myself off and
  33. 'start producing whatever it is I need to produce. Why am I still talking?
  34. 'I have no clue ;)
  35. '-------------------------------------------------------------
  36. 'I got tired of typin all the colors, so
  37. 'I assigned them to a variable. Pretty intellegent aren't I? ;)
  38. Global Const black = &H0&
  39. Global Const grey = &H808080
  40. Global Const green = &H8000&
  41. Global Const red = &HC0&
  42. Global Const fDebug = True
  43.  
  44. 'This is the heart of our code
  45. 'Slot0 is, you guessed it: lblMap index number 0
  46. 'If you don't know what Slot1 through Slot164 is
  47. 'then you better not become a programmer (Just Kidding)
  48. 'We also have the variable for the author, title, difficulty,
  49. 'and a password
  50. Public Type MapDefinition
  51.     Slot0 As Long
  52.     Slot1 As Long
  53.     Slot2 As Long
  54.     Slot3 As Long
  55.     Slot4 As Long
  56.     Slot5 As Long
  57.     Slot6 As Long
  58.     Slot7 As Long
  59.     Slot8 As Long
  60.     Slot9 As Long
  61.     Slot10 As Long
  62.     Slot11 As Long
  63.     Slot12 As Long
  64.     Slot13 As Long
  65.     Slot14 As Long
  66.     Slot15 As Long
  67.     Slot16 As Long
  68.     Slot17 As Long
  69.     Slot18 As Long
  70.     Slot19 As Long
  71.     Slot20 As Long
  72.     Slot21 As Long
  73.     Slot22 As Long
  74.     Slot23 As Long
  75.     Slot24 As Long
  76.     Slot25 As Long
  77.     Slot26 As Long
  78.     Slot27 As Long
  79.     Slot28 As Long
  80.     Slot29 As Long
  81.     Slot30 As Long
  82.     Slot31 As Long
  83.     Slot32 As Long
  84.     Slot33 As Long
  85.     Slot34 As Long
  86.     Slot35 As Long
  87.     Slot36 As Long
  88.     Slot37 As Long
  89.     Slot38 As Long
  90.     Slot39 As Long
  91.     Slot40 As Long
  92.     Slot41 As Long
  93.     Slot42 As Long
  94.     Slot43 As Long
  95.     Slot44 As Long
  96.     Slot45 As Long
  97.     Slot46 As Long
  98.     Slot47 As Long
  99.     Slot48 As Long
  100.     Slot49 As Long
  101.     Slot50 As Long
  102.     Slot51 As Long
  103.     Slot52 As Long
  104.     Slot53 As Long
  105.     Slot54 As Long
  106.     Slot55 As Long
  107.     Slot56 As Long
  108.     Slot57 As Long
  109.     Slot58 As Long
  110.     Slot59 As Long
  111.     Slot60 As Long
  112.     Slot61 As Long
  113.     Slot62 As Long
  114.     Slot63 As Long
  115.     Slot64 As Long
  116.     Slot65 As Long
  117.     Slot66 As Long
  118.     Slot67 As Long
  119.     Slot68 As Long
  120.     Slot69 As Long
  121.     Slot70 As Long
  122.     Slot71 As Long
  123.     Slot72 As Long
  124.     Slot73 As Long
  125.     Slot74 As Long
  126.     Slot75 As Long
  127.     Slot76 As Long
  128.     Slot77 As Long
  129.     Slot78 As Long
  130.     Slot79 As Long
  131.     Slot80 As Long
  132.     Slot81 As Long
  133.     Slot82 As Long
  134.     Slot83 As Long
  135.     Slot84 As Long
  136.     Slot85 As Long
  137.     Slot86 As Long
  138.     Slot87 As Long
  139.     Slot88 As Long
  140.     Slot89 As Long
  141.     Slot90 As Long
  142.     Slot91 As Long
  143.     Slot92 As Long
  144.     Slot93 As Long
  145.     Slot94 As Long
  146.     Slot95 As Long
  147.     Slot96 As Long
  148.     Slot97 As Long
  149.     Slot98 As Long
  150.     Slot99 As Long
  151.     Slot100 As Long
  152.     Slot101 As Long
  153.     Slot102 As Long
  154.     Slot103 As Long
  155.     Slot104 As Long
  156.     Slot105 As Long
  157.     Slot106 As Long
  158.     Slot107 As Long
  159.     Slot108 As Long
  160.     Slot109 As Long
  161.     Slot110 As Long
  162.     Slot111 As Long
  163.     Slot112 As Long
  164.     Slot113 As Long
  165.     Slot114 As Long
  166.     Slot115 As Long
  167.     Slot116 As Long
  168.     Slot117 As Long
  169.     Slot118 As Long
  170.     Slot119 As Long
  171.     Slot120 As Long
  172.     Slot121 As Long
  173.     Slot122 As Long
  174.     Slot123 As Long
  175.     Slot124 As Long
  176.     Slot125 As Long
  177.     Slot126 As Long
  178.     Slot127 As Long
  179.     Slot128 As Long
  180.     Slot129 As Long
  181.     Slot130 As Long
  182.     Slot131 As Long
  183.     Slot132 As Long
  184.     Slot133 As Long
  185.     Slot134 As Long
  186.     Slot135 As Long
  187.     Slot136 As Long
  188.     Slot137 As Long
  189.     Slot138 As Long
  190.     Slot139 As Long
  191.     Slot140 As Long
  192.     Slot141 As Long
  193.     Slot142 As Long
  194.     Slot143 As Long
  195.     Slot144 As Long
  196.     Slot145 As Long
  197.     Slot146 As Long
  198.     Slot147 As Long
  199.     Slot148 As Long
  200.     Slot149 As Long
  201.     Slot150 As Long
  202.     Slot151 As Long
  203.     Slot152 As Long
  204.     Slot153 As Long
  205.     Slot154 As Long
  206.     Slot155 As Long
  207.     Slot156 As Long
  208.     Slot157 As Long
  209.     Slot158 As Long
  210.     Slot159 As Long
  211.     Slot160 As Long
  212.     Slot161 As Long
  213.     Slot162 As Long
  214.     Slot163 As Long
  215.     Slot164 As Long
  216.     Title As String
  217.     Author As String
  218.     Password As String
  219.     Difficulty As Integer
  220. End Type
  221.  
  222. 'A reference to our custom Type
  223. Global Map As MapDefinition
  224.  
  225. 'Hmm...I forgot what this code does...oh yes, it saves the file ;)
  226. Public Function SaveMap(sFileName As String)
  227. On Error GoTo SaveMapError
  228.     'To save our file, we simply open a binary file
  229.     'for output and save everything contained in our
  230.     'custom type that we made at the beginning of this
  231.     'module. No mess, no hassle, and completely free.
  232.     
  233.     'First let's get our own unused file handle
  234.     'so that we don't cause any errors with other
  235.     '(possible) open files.
  236.     Dim FileNum As Long
  237.     FileNum = FreeFile()
  238.     Open sFileName For Binary As #FileNum Len = Len(sFileName)
  239.     'Write our data in the file...
  240.     Put #FileNum, , Map
  241.     '...close the file...
  242.     Close #FileNum
  243.     '...Tell grandpa that everything went as planned...
  244.     SaveMap = "Success"
  245.     '...and exit before we hit our error handler
  246.     Exit Function
  247. SaveMapError:
  248.     'fDebug is a variable I used to turn on and off debugging
  249.     'lines without deleting sever lines of code. Look at the top of
  250.     'this module if you want to turn it off. If you compile it this
  251.     'way, it won't hurt anything and it will be completely invisible
  252.     'to the end user, unless they are running it under Visual Basic
  253.     #If fDebug Then
  254.         'Houston, we have a problem! Ed done busted out the capsule
  255.         'window trying to hit a satelite with a beer bottle!
  256.         Debug.Print "Error " & Err.Number & " " & Err.Description
  257.     #End If
  258.     'Grandpa is gonna be mad...we got 
  259.     Slot to turIis
  260. er boto turn it off. If yored out the capsule
  261.  a saph( hit)6
  262. feer eboto turn it off. If y1pa is gonna be mad.t7pr
  263.  a s" be mad.t7pr
  264.  a s" r.s Loheboto turn it of toto turnf(possLonErrbedone busted out the oton(s ,et of toto turnf(pouo.th other
  265.     '(posDrn iot146 As Long