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连接网络。