home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD176803292001.psc / class.cls < prev    next >
Encoding:
Visual Basic class definition  |  2001-03-28  |  3.5 KB  |  126 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "General"
  10. Attribute VB_GlobalNameSpace = True
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = True
  14. '----------------------------------------------
  15. 'Visual Basic Runtime Procedures Extension
  16. 'Sushant Pandurangi <sushant@phreaker.net>
  17. '-----------------------------------------------
  18. Option Explicit
  19. '-----------------------------------------------
  20. Public Enum EnumErrorCodes
  21.  TYPE_MISMATCH = 13
  22.  ERR_INVALID_CALL = 5
  23.  FILE_DOES_EXIST = 58
  24.  FILE_NOT_FOUND = 53
  25.  UNKNOWN_ERROR = 1
  26.  SUCCESS_DONE = 0
  27.  STACK_OVERFLOW = 6
  28.  OUT_OF_MEMORY = 7
  29. End Enum
  30. '-----------------------------------------------------------
  31.  
  32. Sub AboutBox()
  33. frmAbout.Show vbModal
  34. End Sub
  35.  
  36. Function GetError(Optional ErrNumber As EnumErrorCodes) As String
  37. Attribute GetError.VB_Description = "Get the error message corresponding to the given error number or type."
  38. GetError = Error$(ErrNumber)
  39. End Function
  40.  
  41. Function Decrypt(sText As String, sKey As String) As String
  42. Attribute Decrypt.VB_Description = "Decrypts the given string."
  43.     Dim CipherTest As New Cipher
  44.     CipherTest.KeyString = sKey
  45.     CipherTest.Text = sText
  46.     CipherTest.Shrink
  47.     CipherTest.DoXor
  48.     Decrypt = CipherTest.Text
  49. End Function
  50.  
  51. Function Encrypt(sText As String, sKey As String) As String
  52. Attribute Encrypt.VB_Description = "Encrypts the given string."
  53. Dim CipherTest As New Cipher
  54.     CipherTest.KeyString = sKey
  55.     CipherTest.Text = sText
  56.     CipherTest.DoXor
  57.     CipherTest.Stretch
  58.     Encrypt = CipherTest.Text
  59. End Function
  60.  
  61. Function FileOpen(sFileName As String) As String
  62. Attribute FileOpen.VB_Description = "Opens a file."
  63. 'Its always better to open it as binary
  64. Open sFileName For Binary As #1
  65. FileOpen = Input(LOF(1), 1)
  66. Close #1
  67. End Function
  68.  
  69. Sub FileSave(sFileName As String, sContents As String)
  70. Attribute FileSave.VB_Description = "Saves a file. (Text)"
  71. Open sFileName For Binary As #1
  72. Print #1, sContents
  73. Close #1
  74. End Sub
  75.  
  76. Sub Shortcut(sPath As String, sName As String, sTarget As String, Optional sArguments As String)
  77. Attribute Shortcut.VB_Description = "Create a shortcut."
  78. Dim lReturN
  79. lReturN = fCreateShellLink(sPath, sName, sTarget, sArguments)
  80. End Sub
  81.  
  82. Sub ListFonts(lComboBox As Object)
  83. Attribute ListFonts.VB_Description = "Lists users' fonts."
  84. 'List all user's fonts
  85. Dim i As Integer
  86. For i = 0 To Screen.FontCount - 1
  87. lComboBox.AddItem Screen.Fonts(i)
  88. Next i
  89. End Sub
  90.  
  91. Function ValidFont(vFontName As String) As Boolean
  92. 'Determine if a font exists
  93. Dim i As Integer
  94. For i = 0 To Screen.FontCount - 1
  95. If vFontName = Screen.Fonts(i) Then
  96. ValidFont = True
  97. Exit Function
  98. End If
  99. Next i
  100. End Function
  101.  
  102. Function FixedFont(vFontName As String) As Boolean
  103. 'Determine if a font is fixed-width
  104. Dim i As Integer, imE As frmAbout
  105. Load imE
  106. imE.Hide
  107. imE.Font.Name = vFontName
  108. If imE.TextWidth(".") = imE.TextWidth("W") Then
  109. FixedFont = True
  110. Exit Function
  111. End If
  112. Me.Font.Name = "Tahoma"
  113. FixedFont = False
  114. Unload imE
  115. End Function
  116.  
  117. Function BMPFont(vFontName As String) As Boolean
  118. 'Determine if a font is not a TTF
  119. Load frmAbout
  120. frmAbout.Hide
  121. frmAbout.Font.Name = vFontName
  122. frmAbout.Font.Size = 72.75
  123. If frmAbout.Font.Size <> 72.75 Then BMPFont = False Else BMPFont = True
  124. Unload frmAbout
  125. End Function
  126.