1. 我編寫的vb,想實現連接網路的功能,要用到什麼控制項和函數
用winsock控制項可以實現通過TCP/UDP連接其他網路程序並進行通訊的功能
用internet transfer control控制項可以實現通過HTTP/FTP連接相關伺服器並通訊的功能
以上兩個控制項的具體用法可以參考《VB6.0 控制項參考手冊》(上、下)
2. vb中如何來實現連接網路盤
下記函數試一下。
a_MappedPath:映射路徑
MappedDriveName :映射盤符
a_PathUserName:用戶名
a_PathPassWord:口令
Public Function MapNetDrive(a_MappedPath As String, Optional a_MappedDriveName As String = "Z", Optional a_PathUserName As String = "", Optional a_PathPassWord As String = "") As Boolean
Dim NetR As NETRESOURCE
Dim ErrInfo As Long
With NetR
.dwScope = RESOURCE_GLOBALNET
.dwType = RESOURCETYPE_DISK
.dwDisplayType = RESOURCEDISPLAYTYPE_SHARE
.dwUsage = RESOURCEUSAGE_CONNECTABLE
.lpLocalName = Left(a_MappedDriveName, 1) & ":"
.lpRemoteName = a_MappedPath
End With
ErrInfo = WNetAddConnection2(NetR, a_PathPassWord, a_PathUserName, CONNECT_UPDATE_PROFILE)
MapNetDrive = IIf((ErrInfo = NO_ERROR), True, False)
End Function
用到的API和TYPE
Public Type NETRESOURCE
dwScope As Long
dwType As Long
dwDisplayType As Long
dwUsage As Long
lpLocalName As String
lpRemoteName As String
lpComment As String
lpProvider As String
End Type
Public Declare Function WNetAddConnection2 Lib "mpr.dll" Alias "WNetAddConnection2A" (lpNetResource As NETRESOURCE, ByVal lpPassword As String, ByVal lpUserName As String, ByVal dwFlags As Long) As Long
3. VB如何連接網路資料庫
在工程里找到Microsoft ADO Data Control控制項,拖到窗體上,事件中這么寫:
Private Sub Coammand1_Click()
Adodc1.connectionstring="Driver={SQL Server};Server=伺服器IP;Uid=用戶名;Pwd=密碼;DataBse=資料庫名"
Adodc1.RecordSource="SELECT * FROM 表名 WHERE 條件"
Adodc1.Refrsh
End Sub
要進行數據操作就這樣引用:
Adodc1.RecordSet.Fields("欄位名")這就是操作數據欄位
把Adodc1綁定到數據控制項那就是綁定數據源
4. vb如何連接WiFi
計算機連接wifi,
vb用winsock連接網路。