输入代码的时候为什么老是出现缺少表达式的现象
这是一段调整名称宽度的一段代码,请高手看一下错在哪里,谢谢。Public Declare Function Findwindow Lib "user32" Alias "FindwindowA" _
(ByVallpClassName As String, ByVallpWindowName As String) As Long
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hwnd As Long, _
ByVallpsz1 As String, ByVallpsz2 As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, IParam As Any) As Long
Sub WidenNameBoxDrop2()
Dim Res As Long
Const CB_SETDROPPEDWIDTH = &H160
Const cWidth = 400 * 设定名称方块的宽度
Res = SendMessage(_
FindWindowEx( _
FindWindowEx( _
FindWindow("XLMAIN",Application.Caption) _
,0,"EXCEL;",vbNullString) _
,0,"combobox",vbNullString, _
CB_SETDROPPEDWIDTH,cWidth,0)
End Sub
--------------------编程问答-------------------- 弄清楚每个API的参数共几个,怎么表达,胡乱堆在一起咋行? --------------------编程问答-------------------- 分开写:
Res = Findwindow("XLMAIN", Application.Caption)--------------------编程问答-------------------- 对不起,我的意思是全写上好看,其实就是以下这几行在运行时出现红色,出现表达式不对的提示。我是个新手根本不懂什么代码的,我是按案例抄下练习的时候发现的,和案例对了许多遍了一样的,就是不知这是怎么回事,请高手看错在哪里并进行修改,只要修改后能达到使EXCEL的名称框变宽就行了,谢谢。
Res = FindWindowEx(Res, 0, "EXCEL;", vbNullString)
Res = FindWindowEx(Res, 0, "combobox")
Res = SendMessage(Res, CB_SETDROPPEDWIDTH, cWidth, 0)
Res = SendMessage(_
FindWindowEx( _
FindWindowEx( _
FindWindow("XLMAIN",Application.Caption) _
,0,"EXCEL;",vbNullString) _
,0,"combobox",vbNullString, _
CB_SETDROPPEDWIDTH,cWidth,0)
--------------------编程问答-------------------- 你也不仔细看看,右括号“)”少了一个!!!
代码要简洁,你上面那个叫做API套API,居然套了4层,谁能看懂?
从程序执行的效率来看,简洁的代码执行速度最快,可读性也强。真不知道你在想啥!!! --------------------编程问答-------------------- 不懂,up --------------------编程问答-------------------- 不懂,up --------------------编程问答-------------------- 多谢指点,我只是照案例在练习我不懂编程的,只是在练的时候出现了问题来请教高手,谢谢各位,我按你们的试一下看行不行后再来向各位请教。 --------------------编程问答-------------------- 我试了一下,不能加右括号加上以后就出现编译错误,是无效字符。
补充:VB , VBA