VB程序员博客

VB程序开发

DLL代码
int __stdcall myadd(int a, int b)
{
return a + b;
}

已经导出了.静态调用成功
但是我想用LoadLibrary来调用..不知道怎么写这个代码.(网上看过一个SetWindowText的例子..运行了VB直接弹BUG退出了)

有人能指点下么?

附上我调用不成功的代码..
  Dim hModule As Long, ProcAddress As Long
  hModule = LoadLibrary("c:Demodll.dll")
  If hModule = 0 Then MsgBox "载入DLL失败": Exit Sub
  ProcAddress = GetProcAddress(hModule, "myadd")
  If ProcAddress = 0 Then MsgBox "得函数入口失败": Exit Sub
  CallWindowProc ProcAddress, Me.hWnd, ByVal 0&, ByVal 0&, ByVal 0&
  FreeLibrary hModule不要静态调用..静态的我已经测试通过了.呵呵..谢谢二楼的回复

以上就是静态调用,只不过是显式调用而已。

LoadLibrary 方式,微软不建议使用。

以上就是动态调用,只不过是显式调用而已。
LoadLibrary 方式,微软不建议使用。

VB 不存在静态调用动态库。
不建议使用那就是可以使用.- -可是怎么使用呢..结贴..
解决办法
http://topic.csdn.net/u/20080928/15/287c677b-69e6-432e-9f77-ee58b3fa619f.html


在窗体上有image控件和ImageList控件

求:Image控件调用ImageList的方法.Private Sub Form_Load()
  Me.Picture1.Picture = Me.ImageList1.ListImages(1).Picture
  DoEvents
End Sub
现在有个问题是.
图片是原大,不能自动调节,适应Picture1的窗口大小.
结果,只显示图片的局部,不能显示全部图片.装到ImageList的图片的尺寸是
高541,宽951
在Me.Picture1.Picture只能显示局部,不能显示全部.越绕越乱.
目标需求是
图片框一定Image一定时.装入的图片按自动调节适应到图片框中.

upupup<
CAD配合应用程序.
Sub ls()
  On Error Resume Next
  Dim Ent As AcadEntity
  With ThisDrawing
  For Each Ent In .ModelSpace
  If Ent.Layer = "细实线" Then
  Ent.color = 0
  End If
  Next Ent
  .SelectionSets("*TlsDbx*").Delete
  End With
  Set ss = ThisDrawing.SelectionSets.Add("*TlsDbx*")
  ’ss.AddItems pObj
  Dim pathName, fileName
  pathName = "C:Documents and SettingsAdministrator桌面\压力容器制造VBWMF"
  fileName = "SO_MFM"
  ThisDrawing.Export pathName & fileName, "wmf", ss
  ss.Delete

End Sub


自动编号有数据后,我要把数据库的记录全删除,那它的编号怎样才会再从1开始?Truncate Table tablename
  
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 

http://feiyun0112.cnblogs.com/清空的时候使用如下语句: 
TRUNCATE TABLE TableName 我上次也遇到过这个问题 
就是用TRUNCATE TABLE TableName 这个解决的楼上的全对这好像与VB没关系吧,与数据库有关
不知道你是啥数据库,应该不是ORACLE
我记得ORACLE里是没自动编号的字段,只有序列


Private Sub cmdshangbao_Click()
Dim i, j, k As Integer
Dim int_file As Integer
Dim filename As String
Dim filepath As String
Dim fso1, fso2
Dim fil1, fil2
Dim RetVal
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set fil1 = fso1.CreateTextFile("c:ftp_file.txt", True)
fil1.writeline ("open  192.168.1.120")
fil1.writeline ("user  audit01  123456 ")
Set fso2 = CreateObject("Scripting.FileSystemObject")
Set fil2 = fso2.CreateTextFile("c:ftp_file.bat", True)
fil2.writeline ("ftp -in <  ftp_file.txt")
If Me.ListBox1.ListCount = 0 Then
    MsgBox "没有文件,退出!"
    Exit Sub
End If
int_file = Me.ListBox1.ListCount
For i = 0 To int_file - 1
    filename = Trim(Me.ListBox1.List(i))
    filepath = "put  " & ActiveWorkbook.Path & "" & filename & " " & filename
    fil1.writeline (filepath)
Next
fil1.writeline ("by ")

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus)  '这里总是报无效的过程调用或参数,为啥fil1.Close
fil2.Close
MsgBox "文件上传完成!"
Kill "c:ftp_file.txt"
Kill "c:ftp_file.bat"
End Sub

我在dos下执行c:ftp_file.bat完全正常,为什么?改为
RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus)
试试C/前后各一个空格,vbNormalFocus无所谓.我改成了RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus),
可以为什么出来的ftp命令成了:
d:>ftp -in  0 <ftp_file.txt
而bat中的文件内容为:ftp -in <ftp_file.txt
shell出来的结果多了个0,导致无法连接,为什么?
Shell("cmd /c c:ftp_file.bat")仅是调用cmd.EXE去执行c:ftp_file.bat文件,仅此而已. 去掉参数/c 试一下:
Shell("cmd c:ftp_file.bat")谢谢SYSSZ,已经找到原因
把这两句移到前面就没有问题了

fil1.Close
fil2.Close

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus) 


Private Sub cmdshangbao_Click()
Dim i, j, k As Integer
Dim int_file As Integer
Dim filename As String
Dim filepath As String
Dim fso1, fso2
Dim fil1, fil2
Dim RetVal
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set fil1 = fso1.CreateTextFile("c:ftp_file.txt", True)
fil1.writeline ("open  192.168.1.120")
fil1.writeline ("user  audit01  123456 ")
Set fso2 = CreateObject("Scripting.FileSystemObject")
Set fil2 = fso2.CreateTextFile("c:ftp_file.bat", True)
fil2.writeline ("ftp -in <  ftp_file.txt")
If Me.ListBox1.ListCount = 0 Then
    MsgBox "没有文件,退出!"
    Exit Sub
End If
int_file = Me.ListBox1.ListCount
For i = 0 To int_file - 1
    filename = Trim(Me.ListBox1.List(i))
    filepath = "put  " & ActiveWorkbook.Path & "" & filename & " " & filename
    fil1.writeline (filepath)
Next
fil1.writeline ("by ")

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus)  '这里总是报无效的过程调用或参数,为啥fil1.Close
fil2.Close
MsgBox "文件上传完成!"
Kill "c:ftp_file.txt"
Kill "c:ftp_file.bat"
End Sub

我在dos下执行c:ftp_file.bat完全正常,为什么?改为
RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus)
试试C/前后各一个空格,vbNormalFocus无所谓.我改成了RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus),
可以为什么出来的ftp命令成了:
d:>ftp -in  0 <ftp_file.txt
而bat中的文件内容为:ftp -in <ftp_file.txt
shell出来的结果多了个0,导致无法连接,为什么?
Shell("cmd /c c:ftp_file.bat")仅是调用cmd.EXE去执行c:ftp_file.bat文件,仅此而已. 去掉参数/c 试一下:
Shell("cmd c:ftp_file.bat")谢谢SYSSZ,已经找到原因
把这两句移到前面就没有问题了

fil1.Close
fil2.Close

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus) 


Private Sub cmdshangbao_Click()
Dim i, j, k As Integer
Dim int_file As Integer
Dim filename As String
Dim filepath As String
Dim fso1, fso2
Dim fil1, fil2
Dim RetVal
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set fil1 = fso1.CreateTextFile("c:ftp_file.txt", True)
fil1.writeline ("open  192.168.1.120")
fil1.writeline ("user  audit01  123456 ")
Set fso2 = CreateObject("Scripting.FileSystemObject")
Set fil2 = fso2.CreateTextFile("c:ftp_file.bat", True)
fil2.writeline ("ftp -in <  ftp_file.txt")
If Me.ListBox1.ListCount = 0 Then
    MsgBox "没有文件,退出!"
    Exit Sub
End If
int_file = Me.ListBox1.ListCount
For i = 0 To int_file - 1
    filename = Trim(Me.ListBox1.List(i))
    filepath = "put  " & ActiveWorkbook.Path & "" & filename & " " & filename
    fil1.writeline (filepath)
Next
fil1.writeline ("by ")

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus)  '这里总是报无效的过程调用或参数,为啥fil1.Close
fil2.Close
MsgBox "文件上传完成!"
Kill "c:ftp_file.txt"
Kill "c:ftp_file.bat"
End Sub

我在dos下执行c:ftp_file.bat完全正常,为什么?改为
RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus)
试试C/前后各一个空格,vbNormalFocus无所谓.我改成了RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus),
可以为什么出来的ftp命令成了:
d:>ftp -in  0 <ftp_file.txt
而bat中的文件内容为:ftp -in <ftp_file.txt
shell出来的结果多了个0,导致无法连接,为什么?
Shell("cmd /c c:ftp_file.bat")仅是调用cmd.EXE去执行c:ftp_file.bat文件,仅此而已. 去掉参数/c 试一下:
Shell("cmd c:ftp_file.bat")谢谢SYSSZ,已经找到原因
把这两句移到前面就没有问题了

fil1.Close
fil2.Close

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus) 


Private Sub cmdshangbao_Click()
Dim i, j, k As Integer
Dim int_file As Integer
Dim filename As String
Dim filepath As String
Dim fso1, fso2
Dim fil1, fil2
Dim RetVal
Set fso1 = CreateObject("Scripting.FileSystemObject")
Set fil1 = fso1.CreateTextFile("c:ftp_file.txt", True)
fil1.writeline ("open  192.168.1.120")
fil1.writeline ("user  audit01  123456 ")
Set fso2 = CreateObject("Scripting.FileSystemObject")
Set fil2 = fso2.CreateTextFile("c:ftp_file.bat", True)
fil2.writeline ("ftp -in <  ftp_file.txt")
If Me.ListBox1.ListCount = 0 Then
    MsgBox "没有文件,退出!"
    Exit Sub
End If
int_file = Me.ListBox1.ListCount
For i = 0 To int_file - 1
    filename = Trim(Me.ListBox1.List(i))
    filepath = "put  " & ActiveWorkbook.Path & "" & filename & " " & filename
    fil1.writeline (filepath)
Next
fil1.writeline ("by ")

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus)  '这里总是报无效的过程调用或参数,为啥fil1.Close
fil2.Close
MsgBox "文件上传完成!"
Kill "c:ftp_file.txt"
Kill "c:ftp_file.bat"
End Sub

我在dos下执行c:ftp_file.bat完全正常,为什么?改为
RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus)
试试C/前后各一个空格,vbNormalFocus无所谓.我改成了RetVal = Shell("cmd /c c:ftp_file.bat", vbNormalFocus),
可以为什么出来的ftp命令成了:
d:>ftp -in  0 <ftp_file.txt
而bat中的文件内容为:ftp -in <ftp_file.txt
shell出来的结果多了个0,导致无法连接,为什么?
Shell("cmd /c c:ftp_file.bat")仅是调用cmd.EXE去执行c:ftp_file.bat文件,仅此而已. 去掉参数/c 试一下:
Shell("cmd c:ftp_file.bat")谢谢SYSSZ,已经找到原因
把这两句移到前面就没有问题了

fil1.Close
fil2.Close

RetVal = Shell("c:ftp_file.bat", vbMaximizedFocus) 


用Visual Basic 6.0 如何调用扫描仪 Twain.dll
写得越详细越好,在线等,好用就给分

最重要的是:Twain.dll—-这个东东里边有些什么接口函数,这个最重要! Wang      图象编辑控制 等控件是在win95 和 NT4的,98以后wang都被改成柯达了,98第二版及2000之后的windows系统带的柯达控件和98第一版所带的有一点区别,winXP之后的操作系统就不带有这4个控件了。不过可以将win2000中的控件及一系列动态链接库一起迁移到XP系统中。
我将2000下的这4个空间及支持文件做成了一个安装包,有需要的和我QQ联系:71429660什么呀接分先!


我想实现在VBA程序中调用CHM帮助文档中的某部分。就是实现实时查询帮助文档的功能。可不知道应该怎么做,请各位大侠,指条路,谢谢了。

我不是已经教你了吗,结贴,把分给我方法共享一下??这叫什么玩意儿啊。

App.Help 知道这个吗?


我想实现在VBA程序中调用CHM帮助文档中的某部分。就是实现实时查询帮助文档的功能。可不知道应该怎么做,请各位大侠,指条路,谢谢了。

我不是已经教你了吗,结贴,把分给我方法共享一下??这叫什么玩意儿啊。

App.Help 知道这个吗?