vb如何读取远程文件
Text3.Text=Inet1.OpenURL(""&Text1.Text&"")这个方式是错误的(""&Text1.Text&/xxx.txt"")正确的怎么写?Te...
Text3.Text = Inet1.OpenURL("" & Text1.Text & "")这个方式是错误的("" & Text1.Text &/xxx.txt "")正确的怎么写? Text1.Text等于输入的网站,但是怎么在输入的网站后面加上xxx.txt我想读取xxx.xxx.com/xxx.txt
展开
1个回答
2013-08-01
展开全部
(Text1.Text & “/xxx.txt")& 和 And是两回事 连接字符串用&And是逻辑运算符还有 引号是加在字符串两边的 不要乱加…… 下面还有API实现下载的代码:Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Function DownloadFile(url As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, url, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
Dim a As Boolean, url As String
url = " http://www.baidu.com/img/baidu_logo.gif"
If DownloadFile(url, "C:\1.gif") Then
MsgBox "下载成功!"
End If
End Sub
Public Function DownloadFile(url As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, url, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
Dim a As Boolean, url As String
url = " http://www.baidu.com/img/baidu_logo.gif"
If DownloadFile(url, "C:\1.gif") Then
MsgBox "下载成功!"
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询