可以用多线程吗?

kkttcsd 2001-12-19 06:29:08
将下面的语句可作为一个线程用吗?
Public Sub AsyncThread()
Dim rs As New ADODB.Recordset
Dim str As String

str = "Provider=sqloledb;Data Source=tt;Initial Catalog=tt;uid=sa;pwd=sa;"
rs.Open "select * from tab", str
Set Form1.FGrid.Recordset = rs
End Sub
...全文
64 13 打赏 收藏 举报
写回复
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
jett 2002-02-08
  • 打赏
  • 举报
回复
说错了是FetchComplete事件
executecomplete是用在connection对象上的
jett 2002-02-08
  • 打赏
  • 举报
回复
你可以使用ado的异步记录集
用withevens声明你的recordset对象
dim wthevents rs As ADODB.Recordset
这样就可以编写recordset的事件代码
打开时用adAsyncExecute选项
rs.Open "select * from tab",cn,adopenstatic,adoptimistic,adAsyncExecute
当查询完成会触发executecomplete事件
jamex 2002-02-08
  • 打赏
  • 举报
回复
标题 在Vb下实现多线程 zdm1999(原作)

关键字 Vb多线程



新建一Module
Declare Function CreateThread Lib "kernel32" (lpThreadAttributes As Any, ByVal dwStackSize As Long, ByVal lpStartAddress As Long, lpParameter As Any, ByVal dwCreationFlags As Long, lpThreadID As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Sub main()
Load Form1
Form1.Show
End Sub
Public Sub c1()
.......
End Sub

Public Sub c2()
......
End Sub

新建一窗体

Private hthread1 As Long
Private hthread2 As Long
Private ithread1 As Long
Private ithread2 As Long

Private Sub Command1_Click()

ithread1 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1) --创建线程一
ithread2 = CreateThread(ByVal 0&, ByVal 0&, AddressOf c1, ByVal 0&, ByVal 0&, hthread1) --创建线程二

CloseHandle ithread1 --关闭线程一
CloseHandle ithread2 --关闭线程二

End Sub

Private Sub Form_Load()

End Sub
jdler 2002-02-08
  • 打赏
  • 举报
回复
某些情况还是可以的.
allyfeng 2002-02-08
  • 打赏
  • 举报
回复
vb6里面还是不要用多线程,勉强用了也做不成什么的。限制太多!
Sunnuy 2002-02-08
  • 打赏
  • 举报
回复
vb6不能用多线程。
jdler 2002-02-08
  • 打赏
  • 举报
回复
我试过100%出错退出!!!!:(
好象只要不用Data控制件就可以用多线程!苦啊!呜~~~~~~~~~~~~~~~
kkttcsd 2002-02-08
  • 打赏
  • 举报
回复
u p
kkttcsd 2001-12-21
  • 打赏
  • 举报
回复
u
snakeyin 2001-12-20
  • 打赏
  • 举报
回复
我不會
outer2000 2001-12-20
  • 打赏
  • 举报
回复
VB不提倡用多线程,不安全。
你可以用TIMER控件?
kkttcsd 2001-12-20
  • 打赏
  • 举报
回复
U
kkttcsd 2001-12-20
  • 打赏
  • 举报
回复
u
发帖
VB基础类

7681

社区成员

VB 基础类
社区管理员
  • VB基础类社区
加入社区
帖子事件
创建了帖子
2001-12-19 06:29
社区公告
暂无公告