home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD1267012132000.psc / modUser.bas < prev   
Encoding:
BASIC Source File  |  2000-12-14  |  5.1 KB  |  155 lines

  1. Attribute VB_Name = "modUser"
  2. Option Explicit
  3.  
  4. 'Helps us keep track of the information
  5. Global csServer As SERVER_PROPERTIES
  6. Global csClient As CLIENT_PROPERTIES
  7. Global tFileToSend As FILE_PROPERTIES
  8.  
  9. 'Public types used by csServer, csClient, and tFileToSend
  10. Public Type CLIENT_PROPERTIES
  11.     Status As Integer
  12.     BufferSize As Long
  13. End Type
  14. Public Type FILE_PROPERTIES
  15.     FileLen As Long
  16.     FileName As String
  17.     FilePath As String
  18. End Type
  19. Public Type SERVER_PROPERTIES
  20.     Status As Integer
  21.     BufferSize As Long
  22. End Type
  23. Public Function ParseData(SearchString As String, ArgNum As Integer, Optional Delim As String = ":") As String
  24. '
  25. ' Originally created by Mike Carper (named ExtractArgument)
  26. ' Modified by Arthur Nisnevich for use with this application
  27. '
  28.     On Error GoTo HandleError
  29.     Dim ArgCount As Integer
  30.     Dim LastPos As Integer
  31.     Dim Pos As Integer
  32.     Dim Arg As String
  33.     
  34.     LastPos = 1
  35.     If ArgNum = 1 Then Arg = SearchString
  36.  
  37.     Do While InStr(SearchString, Delim) > 0
  38.         Pos = InStr(LastPos, SearchString, Delim)
  39.  
  40.         If Pos = 0 Then
  41.             If ArgCount = ArgNum - 1 Then Arg = Mid(SearchString, LastPos): Exit Do
  42.         Else
  43.             ArgCount = ArgCount + 1
  44.  
  45.             If ArgCount = ArgNum Then
  46.                 Arg = Mid(SearchString, LastPos, Pos - LastPos): Exit Do
  47.             End If
  48.         End If
  49.         
  50.         LastPos = Pos + 1
  51.     Loop
  52.     
  53.     ParseData = Arg
  54.     Exit Function
  55.     
  56. HandleError:
  57.     MsgBox "Unexpected error occured in function ParseData(). Resuming normal..." & vbNewLine & vbNewLine & _
  58.     "Error " & Err.Number & " : " & Err.Description, vbExclamation, "Unexpected Error"
  59.     Resume Next
  60. End Function
  61.  
  62. Public Function ParseFileName(ByVal strPath As String) As String
  63.     '
  64.     ' NOTE: StrReverse() only works in VB6! If you are using VB5 or below
  65.     ' replace all occurences of this function with the function:
  66.     ' ExtractFileName(). The same principles and arguments apply, however
  67.     ' this method is faster.
  68.     '
  69.     strPath = StrReverse(strPath)
  70.     strPath = Left(strPath, InStr(strPath, "\") - 1)
  71.     ParseFileName = StrReverse(strPath)
  72. End Function
  73. Public Function ParseFilePath(ByVal File$) As String
  74.     '
  75.     ' Written by "anti"
  76.     '
  77.     Dim a, B, C
  78.     
  79.     For a = 1 To Len(File$)
  80.         B = Right(File$, a)
  81.         If Left(B, 1) = "\" Then Exit For
  82.     Next a
  83.     C = Left(File$, Len(File$) - Len(B) + 1)
  84.     ParseFilePath = C
  85. End Function
  86. Public Function ExtractFileName(FilePath) As String
  87.     '
  88.     'ExtractFileName() written by Stewart MacFarlane
  89.     '
  90.     Dim X
  91.     
  92.     For X = Len(FilePath) To 1 Step -1
  93.         If Mid(FilePath, X, 1) = "\" Then
  94.             ExtractFileName = Right(FilePath, Len(FilePath) - X)
  95.             Exit Function
  96.         End If
  97.     Next X
  98. End Function
  99. Public Function DetermineBufferSize() As Long
  100.     Dim rBufferSize As String
  101.     '
  102.     ' NOTE: Even though it should send files superfast to your
  103.     ' own computer, we are using buffering techniques, which
  104.     ' are utilized for TCP, socket streams, and over the Internet
  105.     ' (or a cross-network). Feel free to change these values
  106.     ' if you are planning on using file transfer through a LAN.
  107.     '
  108.     
  109.     'Determines the buffer size by checking the Preset Buffers
  110.     'listbox (and slider).
  111.     Select Case frmMain.cmbPresetBuffers.ListIndex
  112.         Case 0
  113.             DetermineBufferSize = 3072      '< 33.6
  114.         Case 1
  115.             DetermineBufferSize = 5120      '56k
  116.         Case 2 To 6
  117.             '
  118.             ' I am having trouble figuring out why buffering above this
  119.             ' ammount does not work. Feel free to lend a hand :)
  120.             ' For now, I have made it simple and set all buffers above 56k
  121.             ' and below Custom to 10240, which is ISDN speed.
  122.             '
  123.             DetermineBufferSize = 10240     'ISDN (dual/single channel)
  124.         Case 7
  125.             'Get custom buffer size
  126.             rBufferSize = frmMain.txtCustomBuffer
  127.             
  128.             'Do error checking on custom buffer size
  129.             If (rBufferSize = "0") Or (rBufferSize = "") Then
  130.                 'If buffer size is not valid, set default buffer
  131.                 DetermineBufferSize = 5120  '56k
  132.             Else
  133.                 DetermineBufferSize = rBufferSize
  134.             End If
  135.     End Select
  136. End Function
  137. Public Sub PrepareSend(FileSize As String, FileName, FilePath)
  138.     'Prepares the Transfer Progress frame
  139.     With frmMain
  140.         'Sets text values
  141.         .txtFileTransferFile = FileName
  142.         .txtFileSize = FileSize
  143.         .txtLocalFileName = FilePath & FileName
  144.         
  145.         'Sets progress bar maximum to 100 (in case altered manually)
  146.         .pbProgress.Max = 100
  147.     End With
  148.     
  149.     'Sends the tFileToSend type to match the variables passed on
  150.     'from the SendFile() function.
  151.     With tFileToSend
  152.         .FileLen = CLng(FileSize)
  153.         .FileName = CStr(FileName)
  154.         .FilePath = CleName =======ameeLen = CLngtw)etermines nrwlect
  155. Pi3File InStr(SearchString, Dee      '56ke   
  156.    CrOnrwlecte = 512tLe0xor sE