home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / editdemo / editdemo.txt < prev    next >
Text File  |  1991-07-05  |  4KB  |  119 lines

  1. (c) 1991 by Keith Milligan
  2.         100 Lee Road 605
  3.         Smiths, AL 36877
  4.         205-291-9712 Home
  5.         205-298-1974 Work
  6.         Compuserve ID = 70645,520
  7.  
  8. Use these routines if they will help you.  You can use,
  9. modify, copy, or distribute with a clear concience.
  10.  
  11. Visual Basic 1.0 input routines
  12.  
  13. These routine are use two events for each text control.
  14. There is a Sub for the KeyPress event and a corresponding
  15. Function for the LostFocus Event.  The KeyPress (KP) routine
  16. restricts certain keystrokes and the LostFocus (LF) routine
  17. validates the data entered in the text control and assigns
  18. the entered data to a variable.
  19.  
  20.  
  21. Date
  22.   Sub DateKP(ThisControl, KeyAscii)
  23.   Function  DateLF$(ThisControl, EarliestDate$)
  24.   Format of EarliestDate$ is "yymmdd".
  25.   Accepts date enter in one of the following formats:
  26.      60491, 060491, 06/04/91, or 6/4/91
  27.   Returns date in the format 910604.
  28.  
  29. MultPrice
  30.   Sub MultPriceKP(ThisControl, KeyAscii)
  31.   Function MultPriceLF$(ThisControl)
  32.   Used to accept retail prices.  For example 3 for $1.00.
  33.   Accepts and returns in the following formats:
  34.     Input          Returns
  35.      149           01/01.49
  36.      1.49          01/01.49
  37.      3/49          03/00.49
  38.      3/.49         03/00.49
  39.  
  40. Point2
  41.   Sub Point2KP(ThisControl, Length%, KeyAscii)
  42.   Function Point2LF(ThisControl, Min#, Max#)
  43.   Accepts number with two digits to the right of the decimal point.
  44.   Maximum length = Length%
  45.   Minimum value = Min#
  46.   Maximum value = Max#
  47.   Example 123.49
  48.  
  49. Point4
  50.   Sub Point4KP(ThisControl, Length%, KeyAscii)
  51.   Function Point4LF(ThisControl, Min#, Max#)
  52.   Accepts number with four digits to the right of the decimal point.
  53.   Maximum length = Length%
  54.   Minimum value = Min#
  55.   Maximum value = Max#
  56.   Example 123.4978
  57.  
  58. Str
  59.   Sub StrKP(ThisControl, Length%, KeyAscii)
  60.   No LF function for this routine just move text to string in
  61.     LostFocus Event.
  62.   Accepts string of length less than or equal to Length%.
  63.  
  64. UCStr
  65.   Sub UCStrKP(ThisControl, Length%, KeyAscii)
  66.   No LF function for this routine just move text to string in
  67.     LostFocus Event.
  68.   Accepts string of length less than or equal to Length%.
  69.   Converts characters to upper case as typed.
  70.  
  71. Long
  72.   Sub LongKP(ThisControl, Length%, KeyAscii)
  73.   Function LongLF&(ThisControl, Min&, Max&)
  74.   Accepts long integer amount.
  75.  
  76. Int
  77.   Sub IntKP(ThisControl, Length%, KeyAscii)
  78.   Function IntLF%(ThisControl, Min%, Max%)
  79.   Same as Long but accepts normal integer amounts
  80.  
  81. Curr2
  82.   Sub Curr2KP(ThisControl, Length%, KeyAscii)
  83.   Function Curr2LF@(ThisControl, Min@, Max@)
  84.   Same as Point2 but for currency data type.
  85.  
  86. Curr4
  87.   Sub Curr4KP(ThisControl, Length%, KeyAscii)
  88.   Function Curr4LF(ThisControl, Min@, Max@)
  89.   Same as Point4 but for currency data type.
  90.  
  91. DateSer
  92.   Sub DateSerKP(Thiscontrol, KeyAscii)
  93.   Function DateSerLF@(ThisControl, EarliestDate$)
  94.   Same as Date but returns date serial number instead of yymmdd.
  95.  
  96.     
  97. Calling example:
  98.   To call the Point4 routines.
  99.     1.  In the KeyPress event of the text box control with the CtlName
  100.     "Text1" enter the following Sub.
  101.         Sub Text1_KeyPress(KeyAscii As Integer)
  102.           Point4KP Text1, 10, KeyAscii
  103.         End Sub
  104.     This accepts a number with up to four decimal places and up to
  105.     a length of 10 characters.
  106.        
  107.     2.  In the LostFocus event of the same text box control enter the
  108.     following Function.
  109.         Sub Text1_LostFocus()
  110.           CostAmount# = Point4LF(Text1, 1, 1000)
  111.         End Sub
  112.     This sets CostAmount# to the entered amount if the number
  113.     entered is between 1 and 1000. If it is out of range you are
  114.     given a warning message box.
  115.  
  116. The demo program EDITDEMO.EXE must have "vbrun100.dll" available.
  117. It comes with Visual Basic or is available for downloading in the
  118. Microsoft forum's Visual Basic library.
  119.