home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / visual / perl.exe / {app} / Templates / other / Vbasic.vb < prev    next >
Encoding:
Text File  |  2003-01-11  |  2.0 KB  |  40 lines

  1. Attribute VB_Name = "Module1"
  2. # If WIN16 Then
  3.     Declare Function OSWritePrivateProfileString% Lib "KERNEL" Alias "WritePrivateProfileString" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$)
  4.     Declare Function OSGetPrivateProfileString% Lib "KERNEL" Alias "GetPrivateProfileString" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Integer, ByVal FileName$)
  5. # Else
  6.     Declare Function OSWritePrivateProfileString% Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$)
  7.     Declare Function OSGetPrivateProfileString% Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnString$, ByVal NumBytes As Integer, ByVal FileName$)
  8. # End If
  9.  
  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. '--- Check to see if we are in the VB.INI File.  If not, Add ourselves to the INI file
  18.     # If WIN16 Then
  19.         Section$ = "Add-Ins16"
  20.     # Else
  21.         Section$ = "Add-Ins32"
  22.     # End If
  23.     ReturnString = String$(255, Chr$(0))
  24.     ErrCode = OSGetPrivateProfileString(Section$, "Sample.FileEventSpy", "NotFound", ReturnString, Len(ReturnString) + 1, "VB.INI")
  25.     If Left(ReturnString, InStr(ReturnString, Chr(0)) - 1) = "NotFound" Then
  26.         ErrCode = OSWritePrivateProfileString%(Section$, "Sample.FileEventSpy", "0", "VB.INI")
  27.     End If
  28.     SpyShow.Show
  29.     About.Show
  30.     NumberOfEntries = 100
  31. End Sub
  32.  
  33. 'This subroutine essentially adds the passed string to the listbox, and then
  34. 'deletes the oldest entries if the number of entries exceeds the limit
  35. Sub AddEntry(AddString As String)
  36.     SpyShow.List1.AddItem (AddString)
  37.     While SpyShow.List1.ListCount > NumberOfEntries
  38.         SpyShow.List1.RemoveItem 0
  39.     Wend
  40. End Sub