(VB)FTPÒì²½ÏÂÔØ
¸Ã·½·¨²»ÐèҪʹÓÃAPI¼°µÚÈý·½¿Ø¼þ
ÕâÀïʹÓõÄÊÇVBµÄUserControl¿Ø¼þµÄAsyncRead·½·¨
²½ÖèÈçÏÂ:
1¡¢Ìí¼ÓÒ»¸öÓû§¿Ø¼þ£¬ÉèÖÃInvisibleAtRuntimeÊôÐÔΪtrue£¬Ä¿µÄÊÇÔËÐÐʱ¸Ã¿Ø¼þ²»ÏÔʾÓû§½çÃæ£¬¾ÍÏóTimer¿Ø¼þÒ»Ñù¡£
2¡¢µ½×Ô¶¨Òå¿Ø¼þµÄ´úÂë´°¿Ú£¬Ìí¼ÓÈçÏ´úÂë
Option Explicit
'ÏÂÔØ½á¹ûö¾Ù
Public Enum DownloadResults
eSUCCESS = 0 'ÏÂÔØ³É¹¦
eCONNECTERROR = 1 'Á¬½Ó´íÎó
eTRANSFERERROR = 2 'Êý¾Ý´«Êä´íÎó
eWRITEERROR = 3 '±£´æ±¾µØ´íÎó
eUserStop = 4 'ÖÐÖ¹
End Enum
'ÏÂÔØ½ø¶Èʼþ Identifier-ÏÂÔØ±êʶ,RecvdBytes-ÒÑÏÂÔØ×Ö½ÚÊý,MaxBytes-×Ü×Ö½ÚÊý,PassTimer-ÒÑÓÃÏÂÔØÊ±¼ä(Ãë)
Public Event DownloadProgress(Identifier As String, RecvdBytes As Long, MaxBytes As Long, PassTimer As Long)
'ÏÂÔØÍê³Éʼþ Identifier-ÏÂÔØ±êʶ,ccDownloadResults-ÏÂÔØ½á¹û,PassTimer-ÒÑÓÃÏÂÔØÊ±¼ä(Ãë)
Public Event DownloadComplete(Identifier As String, Result As DownloadResults, PassTimer As Long)
Dim FstrURL As String 'FTP ÏÂÔØ×Ö·û´®,º¬IP,¶Ë¿ÚºÅ,Óû§Ãû,ÃÜÂë,ÏÂÔØµÄÎļþ¼°Æä·¾¶
Dim FstrSaveFile As String 'ÏÂÔØµÄÎļþ±£´æÔÚ±¾µØµÄÎļþÃû¼°Æä·¾¶
Dim FstrIdentifier As String 'ÏÂÔØ±êʶ
Dim FlngStart As Long '¿ªÊ¼ÏÂÔØÊ±¼ä
'ÏÂÔØÎļþ
'strURL FTP ÏÂÔØ×Ö·û´®,º¬IP,¶Ë¿ÚºÅ,Óû§Ãû,ÃÜÂë,ÏÂÔØµÄÎļþ¼°Æä·¾¶
' ÐÎÈç ftp://Óû§Ãû:ÃÜÂë@FTPµØÖ·/Ŀ¼/Îļþ
'strSaveFile ±£´æÊ±µÄ±¾µØÎļþÃû
'strIdentifier ÏÂÔØ±êʶ,¿ÉÒÔͬʱÏÂÔØ¶à¸öÎļþ,ÒÀ¾Ý´Ë×Ö·û´®Çø±ðËùÏÂÔØµÄÎļþ
Public Sub DownLoad(ByVal strURL As String, ByVal strSaveFile As String, ByVal strIdentifier As String)
On Error GoTo ERRHAND
FstrURL = strURL
FstrSaveFile = strSaveFile
FstrIdentifier = strIdentifier
FlngStart = Timer
UserControl.AsyncRead strURL, vbAsyncTypeByteArray, strIdentifier, vbAsyncReadForceUpdate
Exit Sub
ERRHAND:
RaiseEvent DownloadComplete(strIdentifier, eCONNECTERROR, Timer - FlngStart)
End Sub
Private Sub UserControl_AsyncReadComplete(AsyncProp As AsyncProperty)
On Error GoTo Errs
Ïà¹ØÎĵµ£º
Ê®Ììѧ»áASP.net֮ʵսϵÁУ¨C#ºÍVb.netË«°æ±¾£©
µÚÒ»Ìì
ÎÒÈÏΪASP.NET±ÈASPÄѺܶ࣬ϣÍû´ó¼Ò×öºÃ×¼±¸¡£ÄÑÄÑÔÚʵÏÖͬһ¸öЧ¹ûÓкܶ෽·¨£¬´ó¼Ò»òÐí»áÒÉ»ó¡£Ê®Ììѧ»áϵÁн̳̻áÇåÎúµÄд³ö¸÷ÖÖ·½·¨£¬Èôó¼ÒÄÜÉÙÒ»µã¿²¿À¡£ÔÚASPÀïÃæ£¬´ó¼Ò¼¸ºõ¶¼ÊÇʹÓÃVB£¬Êý¾Ý¿âÂҲÎÞ·ÇÊÇSQLºÍACCESS¡£ÔÚASP.NETÀïÃæ£¬Êý¾Ý¿â»¹ÊÇÕ ......
ÔÚVBÖÐÒªÏëµ÷ÓÃExcel£¬ÐèÒª´ò¿ªVB±à³Ì»·¾³“¹¤³Ì”²Ëµ¥ÖеēÒýÓÔÏîÄ¿£¬²¢Ñ¡È¡ÏîÄ¿ÖеēMicrosoft Excel 11.0 object library”Ïî¡£ÓÉÓÚÄãµÄExcel°æ±¾²»Í¬£¬ËùÒÔÕâ¸öÑ¡ÏîµÄ°æ±¾ºÅÒ²ÊDz»Í¬µÄ¡£
ÒòΪEXCELÊÇÒÔ²ã´Î½á¹¹×éÖ¯¶ÔÏóµÄ£¬Æä¶ÔÏóÄ£ÐÍÖк¬ÓÐÐí¶à²»Í¬µÄ¶ÔÏóÔªËØ¡£
&n ......
'´´½¨Êý¾Ý¿â
Private Sub Create(ByVal mdbPath As String)
If File.Exists(mdbPath) Then
Throw New Exception("Ä¿±êÊý¾Ý¿âÒѾ´æÔÚ£¬ÎÞ·¨´´½¨")
......
vbʹÓÃopen·½·¨¶ÁдÎļþ
£¨Ò»£©´ò¿ªºÍ¹Ø±ÕÎļþ
¡¡¡¡1¡¢Ë³ÐòÎļþ
¡¡¡¡´ò¿ªË³ÐòÎļþ£¬ÎÒÃÇ¿ÉÒÔʹÓÃOpenÓï¾ä¡£ËüµÄ¸ñʽÈçÏ£º
Open pathname For [Input |Output |Append] As [#]filenumber [Len = buffersize]
¡¡¡¡ËµÃ÷£º
¡¡¡¡£¨1£©²ÎÊýpathname ±íʾҪ´ò¿ªµÄÎļþÃû£¬ÎļþÃû¿ÉÒÔ°üº¬ÓÐÇý¶¯Æ÷ºÍÄ¿ ......
Option Explicit
Public Function ascii2Char(strInput As String) As String
Dim i As Integer
Dim strTemp As String
Dim nPos As Integer
Dim nValue As Integer
i = 1
nPos = InStr(i, strInput, "&#", vbTextCompare)
While (nPos > 0)
ascii2Char = ascii2Char + Left(st ......