home *** CD-ROM | disk | FTP | other *** search
/ Master 95 #1 / MASTER95_1.iso / microsof / vbasic4 / vb4-6.cab / main1.bas < prev    next >
Encoding:
BASIC Source File  |  1995-07-26  |  2.1 KB  |  47 lines

  1. Attribute VB_Name = "MainModule"
  2. Option Explicit
  3. #If Win16 Then
  4.     Declare Function WritePrivateProfileString Lib "KERNEL" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$) As Integer
  5.     Declare Function GetPrivateProfileString Lib "KERNEL" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Integer, ByVal FileName$) As Integer
  6. #Else
  7.     Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$) As Long
  8.     Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Long, ByVal FileName$) As Long
  9. #End If
  10.  
  11. 'How many entries are we going to allow in the ListBox? One modification
  12. 'is to let the user set the number of entries we keep.
  13. Private NumberOfEntries As Long
  14.  
  15. Sub Main()
  16. Dim ReturnString As String
  17. Dim Section$
  18. '--- Check to see if we are in the VB.INI File.  If not, Add ourselves to the INI file
  19.     #If Win16 Then
  20.         Section$ = "Add-Ins16"
  21.     #Else
  22.         Section$ = "Add-Ins32"
  23.     #End If
  24.     'Check to see if the Align.Connector entry is already in the VB.INI file.  Add if not.
  25.     ReturnString = String$(255, Chr$(0))
  26.     GetPrivateProfileString Section$, "SpySample.FileEventSpy", "NotFound", ReturnString, Len(ReturnString) + 1, "VB.INI"
  27.     If Left(ReturnString, InStr(ReturnString, Chr(0)) - 1) = "NotFound" Then
  28.         WritePrivateProfileString Section$, "SpySample.FileEventSpy", "0", "VB.INI"
  29.     End If
  30.     
  31.     NumberOfEntries = 100
  32. End Sub
  33.  
  34. 'This subroutine essentially adds the passed string to the listbox, and then
  35. 'deletes the oldest entries if the number of entries exceeds the limit
  36. Sub AddEntry(AddString As String)
  37. Dim i%
  38.     With SpyShow.lstEvents
  39.         .AddItem AddString
  40.         For i% = 1 To .ListCount - NumberOfEntries
  41.             .RemoveItem 0
  42.         Next i%
  43.         .ListIndex = .ListCount - 1
  44.     End With
  45. End Sub
  46.  
  47.