home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / ENTRPRIS / APE / INCLUDE / MODAEGLB.BAS < prev    next >
Encoding:
BASIC Source File  |  1996-12-06  |  2.6 KB  |  79 lines

  1. Attribute VB_Name = "modAEGlobals"
  2. Option Explicit
  3.  
  4. '==================================================
  5. ' Routine: ReplaceString
  6. '
  7. ' Purpose: Replaces specified string in a target
  8. '          string with a new string
  9. ' Arguments:
  10. '   sTarget: string to work on
  11. '   sSearch: string to replace in sTarget
  12. '   sNew: value to replace sSearch with
  13. ' Outputs:
  14. '   Revised version of sTarget (Note: sTarget is
  15. '   NOT modified.)
  16. '==================================================
  17. Function ReplaceString(ByVal sTarget As String, sSearch As String, sNew As String) As String
  18.     Dim p As Integer
  19.     Do
  20.         p = InStr(sTarget, sSearch)
  21.         If p Then
  22.             sTarget = Left(sTarget, p - 1) + sNew + Mid(sTarget, p + Len(sSearch))
  23.         End If
  24.     Loop While p
  25.     ReplaceString = sTarget
  26. End Function
  27.  
  28. '==================================================
  29. ' Routine: Round
  30. '
  31. ' Purpose: Converts the passed Single value to the
  32. '          nearest integer value
  33. '          In contrast to CInt or Clng which convert
  34. '          single values to the nearest even integer
  35. '==================================================
  36. Public Function Round(sngIn As Single) As Long
  37.     If (sngIn Mod 1) < 0.5 Then
  38.         Round = Fix(sngIn)
  39.     Else
  40.         Round = Fix(sngIn) + 1
  41.     End If
  42. End Function
  43.  
  44. '==================================================
  45. ' Routine: ApplyFontToForm
  46. '
  47. ' Purpose: Applies a font name and font size from
  48. '          a string resource to every control of a form
  49. '==================================================
  50. Public Sub ApplyFontToForm(frmApply As Form, iKeyOfFontName As Integer, iKeyOfFontSize As Integer, iKeyOfCharset As Integer)
  51.     On Error Resume Next
  52.     Dim fntApply As Object
  53.     Dim ctlApply As Control
  54.     
  55.     Set fntApply = frmApply.Font
  56.     fntApply.Name = LoadResString(iKeyOfFontName)
  57.     fntApply.Size = CInt(LoadResString(iKeyOfFontSize))
  58.     fntApply.Charset = CInt(LoadResString(iKeyOfCharset))
  59.     
  60.     For Each ctlApply In frmApply.Controls
  61.         Set ctlApply.Font = fntApply
  62.     Next
  63. End Sub
  64.  
  65. Public Function FormatPath(sPath As String) As String
  66.     '-------------------------------------------------------------------------
  67.     'Purpose:   Assures that the passed path has a "\" at the end of it
  68.     'IN:
  69.     '   [sPath]
  70.     '           a valid path name
  71.     'Return:    the same path with a "\" on the end if it did not already
  72.     '           have one.
  73.     '-------------------------------------------------------------------------
  74.     If Right$(sPath, 1) <> "\" Then sPath = sPath & "\"
  75.     FormatPath = sPath
  76. End Function
  77.  
  78.  
  79.