home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Program_Up52528222002.psc / downloader / modDownload.bas < prev   
Encoding:
BASIC Source File  |  2002-02-03  |  3.1 KB  |  94 lines

  1. Attribute VB_Name = "modDownload"
  2. Option Explicit
  3.  
  4. Global strSvrURL As String
  5. Global Url As String
  6. Global RESUMEFILE As Boolean
  7. Global FilePathName As String
  8. Global Filename As String
  9. Global FileLength As Single
  10. Global Sec%, Min%, Hr%
  11. Public Const SW_NORMAL = 1
  12. Public strFormLoaded As String
  13. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  14. Public Const SW_SHOWMAXIMIZED = 3
  15. Public Const SW_SHOWNORMAL = 1
  16. Public Const SW_SHOW = 5
  17.  
  18. Public Function File_ByteConversion(NumberOfBytes As Single) As String
  19. On Error Resume Next
  20.     If NumberOfBytes < 1024 Then 'checks to see if its so small that it cant be converted into larger grouping
  21.         File_ByteConversion = NumberOfBytes & " Bytes"
  22.     
  23.     End If
  24.     
  25.     If NumberOfBytes > 1024 Then  'Checks to see if file is big enough to convert into KB
  26.         File_ByteConversion = Format(NumberOfBytes / 1024, "0.00") & " KB"
  27.     
  28.     End If
  29.     
  30.     If NumberOfBytes > 1024000 Then 'Checks to see if its big enough to convert into MB
  31.         File_ByteConversion = Format(NumberOfBytes / 1024000, "###,###,##0.00") & " MB"
  32.     
  33.     End If
  34.     
  35. End Function
  36.  
  37. Public Function UpdateProgress(pb As Control, ByVal Percent)
  38. 'Replacement for progress bar..looks nicer also
  39. Dim Num$ 'use percent
  40.     If Not pb.AutoRedraw Then 'picture in memory ?
  41.         pb.AutoRedraw = -1 'no, make one
  42.     
  43.     End If
  44.     
  45.     pb.Cls 'clear picture in memory
  46.     pb.ScaleWidth = 100 'new sclaemodus
  47.     pb.DrawMode = 10 'not XOR Pen Modus
  48.     Num$ = Format$(Percent, "###") + "%"
  49.     pb.CurrentX = 50 - pb.TextWidth(Num$) / 2
  50.     pb.CurrentY = (pb.ScaleHeight - pb.TextHeight(Num$)) / 2
  51.     pb.Print Num$ 'print percent
  52.     pb.Line (0, 0)-(Percent, pb.ScaleHeight), , BF
  53.     pb.Refresh 'show differents
  54.     
  55. End Function
  56.  
  57. Public Function FileCheck(Path$) As Boolean
  58.  
  59.     FileCheck = True 'Assume Success
  60.     On Error Resume Next
  61.     Dim Disregard As Long
  62.     Disregard = FileLen(Path)
  63.         If Err <> 0 Then
  64.             FileCheck = False
  65.         End If
  66.     
  67. End Function
  68.  
  69. Public Function GETDATAHEAD(Data As Variant, ToRetrieve As String)
  70.     On Error Resume Next
  71.         If Data = "" Then Exit Function
  72.         Dim EndBYTES%, a$, LENGTHEND%, PART%, Part2%, RetrieveLength%
  73.             If InStr(Data, ToRetrieve) > 0 Then
  74.                 LENGTHEND = Len(Data)
  75.                 PART = InStr(Data, ToRetrieve)
  76.                 RetrieveLength = Len(ToRetrieve)
  77.                 a = Right(Data, LENGTHEND - PART - RetrieveLength)
  78.                 LENGTHEND = Len(a)
  79.                 If InStr(a, vbCrLf) > 0 Then
  80.                 Part2 = InStr(a, vbCrLf)
  81.                 a = Left(a, Part2 - 1)
  82.             End If
  83.             
  84.         GETDATAHEAD = a
  85.         
  86.         End If
  87. End Function
  88.  
  89. Public Function OpenIt(Frm As Form, ToOpen As String)
  90.     ShellExecute Frm.hwnd, "Open", ToOpen, &O0, &O0, SW_NORMAL
  91.  
  92. End Function
  93.  
  94.